Zelda Classic Coverage Report


Directory: src/
File: src/zc/zc_sys.cpp
Date: 2023-02-19 14:16:19
Exec Total Coverage
Lines: 1716 3948 43.5%
Functions: 126 338 37.3%
Branches: 937 2720 34.4%

Line Branch Exec Source
1 //--------------------------------------------------------
2 // Zelda Classic
3 // by Jeremy Craner, 1999-2000
4 //
5 // zc_sys.cc
6 //
7 // System functions, input handlers, GUI stuff, etc.
8 // for Zelda Classic.
9 //
10 //--------------------------------------------------------
11
12 // to prevent <map> from generating errors
13 #define __GTHREAD_HIDE_WIN32API 1
14
15 #include "precompiled.h" //always first
16 #include "zc_sys.h"
17
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <string.h>
21 #include <math.h>
22 #include <map>
23 #include <filesystem>
24 #include <ctype.h>
25 #include <sstream>
26 #include "base/zc_alleg.h"
27 #include "gamedata.h"
28 #include "zc_init.h"
29 #include "init.h"
30 #include "replay.h"
31 #include "cheats.h"
32 #include "render.h"
33 #include "base/zc_math.h"
34 #include "base/zapp.h"
35
36 #ifdef ALLEGRO_DOS
37 #include <unistd.h>
38 #endif
39
40 #include "metadata/metadata.h"
41 #include "zelda.h"
42 #include "tiles.h"
43 #include "base/colors.h"
44 #include "pal.h"
45 #include "base/zsys.h"
46 #include "qst.h"
47 #include "zc_sys.h"
48 #include "play_midi.h"
49 #include "debug.h"
50 #include "jwin.h"
51 #include "base/jwinfsel.h"
52 #include "base/gui.h"
53 #include "midi.h"
54 #include "subscr.h"
55 #include "maps.h"
56 #include "sprite.h"
57 #include "guys.h"
58 #include "hero.h"
59 #include "title.h"
60 #include "particles.h"
61 #include "zconsole.h"
62 #include "ffscript.h"
63 #include "dialog/info.h"
64 #include "dialog/alert.h"
65 #include <fmt/format.h>
66
67 #ifdef __EMSCRIPTEN__
68 #include "base/emscripten_utils.h"
69 #endif
70
71 extern FFScript FFCore;
72 extern bool Playing;
73 int32_t sfx_voice[WAV_COUNT];
74 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c);
75 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c);
76
77 extern byte monochrome_console;
78
79 extern FONT *lfont;
80 extern HeroClass Hero;
81 extern FFScript FFCore;
82 extern ZModule zcm;
83 extern zcmodule moduledata;
84 extern sprite_list guys, items, Ewpns, Lwpns, Sitems, chainlinks, decorations;
85 extern particle_list particles;
86 extern int32_t loadlast;
87 extern word passive_subscreen_doscript;
88 extern bool passive_subscreen_waitdraw;
89 byte use_dwm_flush;
90 byte use_save_indicator;
91 byte midi_patch_fix;
92 bool midi_paused=false;
93 int32_t paused_midi_pos = 0;
94 byte midi_suspended = 0;
95 byte callback_switchin = 0;
96 byte zc_192b163_warp_compatibility;
97 char modulepath[2048];
98 byte epilepsyFlashReduction;
99 signed char pause_in_background_menu_init = 0;
100 byte pause_in_background = 0;
101 bool is_sys_pal = false;
102 static bool load_control_called_this_frame;
103 extern PALETTE* hw_palette;
104 extern bool update_hw_pal;
105 extern const char* dmaplist(int32_t index, int32_t* list_size);
106
107
108 extern bool kb_typing_mode; //script only, for disbaling key presses affecting Hero, etc.
109 extern int32_t cheat_modifier_keys[4]; //two options each, default either control and either shift
110 //extern byte refresh_select_screen;
111 //extern movingblock mblock2; //mblock[4]?
112 //extern int32_t db;
113
114 static const char *ZC_str = "Zelda Classic";
115 extern char save_file_name[1024];
116 #ifdef ALLEGRO_DOS
117 const char *qst_dir_name = "dos_qst_dir";
118 #elif defined(ALLEGRO_WINDOWS)
119 const char *qst_dir_name = "win_qst_dir";
120 static const char *qst_module_name = "current_module";
121 #elif defined(ALLEGRO_LINUX)
122 const char *qst_dir_name = "linux_qst_dir";
123 static const char *qst_module_name = "current_module";
124 #elif defined(__APPLE__)
125 const char *qst_dir_name = "osx_qst_dir";
126 static const char *qst_module_name = "current_module";
127 #endif
128 #ifdef ALLEGRO_LINUX
129 static const char *samplepath = "samplesoundset/patches.dat";
130 #endif
131 char qst_files_path[2048];
132
133 #ifdef _MSC_VER
134 #define getcwd _getcwd
135 #endif
136
137 bool rF11();
138 bool rI();
139 bool rQ();
140 bool zc_key_pressed();
141
142 #ifdef _WIN32
143
144 // This should only be necessary for MinGW, since it doesn't have a dwmapi.h. Add another #ifdef if you like.
145 extern "C"
146 {
147 typedef HRESULT(WINAPI *t_DwmFlush)();
148 typedef HRESULT(WINAPI *t_DwmIsCompositionEnabled)(BOOL *pfEnabled);
149 }
150
151 void do_DwmFlush()
152 {
153 static HMODULE shell = LoadLibrary("dwmapi.dll");
154
155 if(!shell)
156 return;
157
158 static t_DwmFlush flush=reinterpret_cast<t_DwmFlush>(GetProcAddress(shell, "DwmFlush"));
159 static t_DwmIsCompositionEnabled isEnabled=reinterpret_cast<t_DwmIsCompositionEnabled>(GetProcAddress(shell, "DwmIsCompositionEnabled"));
160
161 BOOL enabled;
162 isEnabled(&enabled);
163
164 if(isEnabled)
165 flush();
166 }
167
168 #endif // _WIN32
169
170 // Dialogue largening
171 void large_dialog(DIALOG *d)
172 {
173 large_dialog(d, 1.5);
174 }
175
176 void large_dialog(DIALOG *d, float RESIZE_AMT)
177 {
178 if(!d[0].d1)
179 {
180 d[0].d1 = 1;
181 int32_t oldwidth = d[0].w;
182 int32_t oldheight = d[0].h;
183 int32_t oldx = d[0].x;
184 int32_t oldy = d[0].y;
185 d[0].x -= int32_t(d[0].w/RESIZE_AMT);
186 d[0].y -= int32_t(d[0].h/RESIZE_AMT);
187 d[0].w = int32_t(d[0].w*RESIZE_AMT);
188 d[0].h = int32_t(d[0].h*RESIZE_AMT);
189
190 for(int32_t i=1; d[i].proc !=NULL; i++)
191 {
192 // Place elements horizontally
193 double xpc = ((double)(d[i].x - oldx) / (double)oldwidth);
194 d[i].x = int32_t(d[0].x + (xpc*d[0].w));
195
196 if(d[i].proc != d_stringloader)
197 {
198 if(d[i].proc==d_bitmap_proc)
199 {
200 d[i].w *= 2;
201 }
202 else d[i].w = int32_t(d[i].w*RESIZE_AMT);
203 }
204
205 // Place elements vertically
206 double ypc = ((double)(d[i].y - oldy) / (double)oldheight);
207 d[i].y = int32_t(d[0].y + (ypc*d[0].h));
208
209 // Vertically resize elements
210 if(d[i].proc == jwin_edit_proc || d[i].proc == jwin_check_proc || d[i].proc == jwin_checkfont_proc)
211 {
212 d[i].h = int32_t((double)d[i].h*1.5);
213 }
214 else if(d[i].proc == jwin_droplist_proc)
215 {
216 d[i].y += int32_t((double)d[i].h*0.25);
217 d[i].h = int32_t((double)d[i].h*1.25);
218 }
219 else if(d[i].proc==d_bitmap_proc)
220 {
221 d[i].h *= 2;
222 }
223 else d[i].h = int32_t(d[i].h*RESIZE_AMT);
224
225 // Fix frames
226 if(d[i].proc == jwin_frame_proc)
227 {
228 d[i].x++;
229 d[i].y++;
230 d[i].w-=4;
231 d[i].h-=4;
232 }
233 }
234 }
235
236 for(int32_t i=1; d[i].proc!=NULL; i++)
237 {
238 if(d[i].proc==jwin_slider_proc)
239 continue;
240
241 // Bigger font
242 bool bigfontproc = (d[i].proc != d_midilist_proc && d[i].proc != jwin_droplist_proc && d[i].proc != jwin_abclist_proc && d[i].proc != jwin_list_proc);
243
244 if(!d[i].dp2 && bigfontproc)
245 {
246 //d[i].dp2 = (d[i].proc == jwin_edit_proc) ? sfont3 : lfont_l;
247 d[i].dp2 = lfont_l;
248 }
249 else if(!bigfontproc)
250 {
251 // ((ListData *)d[i].dp)->font = &sfont3;
252 ((ListData *)d[i].dp)->font = &lfont_l;
253 }
254
255 // Make checkboxes work
256 if(d[i].proc == jwin_check_proc)
257 d[i].proc = jwin_checkfont_proc;
258 else if(d[i].proc == jwin_radio_proc)
259 d[i].proc = jwin_radiofont_proc;
260 }
261
262 jwin_center_dialog(d);
263 }
264
265
266 /**********************************/
267 /******** System functions ********/
268 /**********************************/
269
270 static char cfg_sect[] = "zeldadx"; //We need to rename this.
271 static char ctrl_sect[] = "Controls";
272 static char sfx_sect[] = "Volume";
273
274 int32_t d_dummy_proc(int32_t,DIALOG *,int32_t)
275 {
276 return D_O_K;
277 }
278
279 28 void load_game_configs()
280 {
281 28 strcpy(moduledata.module_name,zc_get_config("ZCMODULE",qst_module_name,"classic.zmod"));
282 28 joystick_index = zc_get_config(ctrl_sect,"joystick_index",0);
283 28 js_stick_1_x_stick = zc_get_config(ctrl_sect,"js_stick_1_x_stick",0);
284 28 js_stick_1_x_axis = zc_get_config(ctrl_sect,"js_stick_1_x_axis",0);
285 28 js_stick_1_x_offset = zc_get_config(ctrl_sect,"js_stick_1_x_offset",0) ? 128 : 0;
286 28 js_stick_1_y_stick = zc_get_config(ctrl_sect,"js_stick_1_y_stick",0);
287 28 js_stick_1_y_axis = zc_get_config(ctrl_sect,"js_stick_1_y_axis",1);
288 28 js_stick_1_y_offset = zc_get_config(ctrl_sect,"js_stick_1_y_offset",0) ? 128 : 0;
289 28 js_stick_2_x_stick = zc_get_config(ctrl_sect,"js_stick_2_x_stick",1);
290 28 js_stick_2_x_axis = zc_get_config(ctrl_sect,"js_stick_2_x_axis",0);
291 28 js_stick_2_x_offset = zc_get_config(ctrl_sect,"js_stick_2_x_offset",0) ? 128 : 0;
292 28 js_stick_2_y_stick = zc_get_config(ctrl_sect,"js_stick_2_y_stick",1);
293 28 js_stick_2_y_axis = zc_get_config(ctrl_sect,"js_stick_2_y_axis",1);
294 28 js_stick_2_y_offset = zc_get_config(ctrl_sect,"js_stick_2_y_offset",0) ? 128 : 0;
295 28 analog_movement = (zc_get_config(ctrl_sect,"analog_movement",1));
296
297 //cheat modifier keya
298 28 cheat_modifier_keys[0] = zc_get_config(ctrl_sect,"key_cheatmod_a1",KEY_ZC_LCONTROL);
299 28 cheat_modifier_keys[1] = zc_get_config(ctrl_sect,"key_cheatmod_a2",0);
300 28 cheat_modifier_keys[2] = zc_get_config(ctrl_sect,"key_cheatmod_b1",KEY_ZC_RCONTROL);
301 28 cheat_modifier_keys[3] = zc_get_config(ctrl_sect,"key_cheatmod_b2",0);
302
303
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if((uint32_t)joystick_index >= MAX_JOYSTICKS)
304 joystick_index = 0;
305
306 28 Akey = zc_get_config(ctrl_sect,"key_a",KEY_Z);
307 28 Bkey = zc_get_config(ctrl_sect,"key_b",KEY_X);
308 28 Skey = zc_get_config(ctrl_sect,"key_s",KEY_ENTER);
309 28 Lkey = zc_get_config(ctrl_sect,"key_l",KEY_Q);
310 28 Rkey = zc_get_config(ctrl_sect,"key_r",KEY_W);
311 28 Pkey = zc_get_config(ctrl_sect,"key_p",KEY_SPACE);
312 28 Exkey1 = zc_get_config(ctrl_sect,"key_ex1",KEY_A);
313 28 Exkey2 = zc_get_config(ctrl_sect,"key_ex2",KEY_S);
314 28 Exkey3 = zc_get_config(ctrl_sect,"key_ex3",KEY_D);
315 28 Exkey4 = zc_get_config(ctrl_sect,"key_ex4",KEY_C);
316
317 28 DUkey = zc_get_config(ctrl_sect,"key_up", KEY_UP);
318 28 DDkey = zc_get_config(ctrl_sect,"key_down", KEY_DOWN);
319 28 DLkey = zc_get_config(ctrl_sect,"key_left", KEY_LEFT);
320 28 DRkey = zc_get_config(ctrl_sect,"key_right",KEY_RIGHT);
321
322 28 Abtn = zc_get_config(ctrl_sect,"btn_a",2);
323 28 Bbtn = zc_get_config(ctrl_sect,"btn_b",1);
324 28 Sbtn = zc_get_config(ctrl_sect,"btn_s",10);
325 28 Mbtn = zc_get_config(ctrl_sect,"btn_m",9);
326 28 Lbtn = zc_get_config(ctrl_sect,"btn_l",5);
327 28 Rbtn = zc_get_config(ctrl_sect,"btn_r",6);
328 28 Pbtn = zc_get_config(ctrl_sect,"btn_p",12);
329 28 Exbtn1 = zc_get_config(ctrl_sect,"btn_ex1",7);
330 28 Exbtn2 = zc_get_config(ctrl_sect,"btn_ex2",8);
331 28 Exbtn3 = zc_get_config(ctrl_sect,"btn_ex3",4);
332 28 Exbtn4 = zc_get_config(ctrl_sect,"btn_ex4",3);
333
334 28 DUbtn = zc_get_config(ctrl_sect,"btn_up",13);
335 28 DDbtn = zc_get_config(ctrl_sect,"btn_down",14);
336 28 DLbtn = zc_get_config(ctrl_sect,"btn_left",15);
337 28 DRbtn = zc_get_config(ctrl_sect,"btn_right",16);
338
339 28 epilepsyFlashReduction = zc_get_config(cfg_sect,"epilepsy_flash_reduction",0);
340
341 28 digi_volume = zc_get_config(sfx_sect,"digi",248);
342 28 midi_volume = zc_get_config(sfx_sect,"midi",255);
343 28 sfx_volume = zc_get_config(sfx_sect,"sfx",248);
344 28 emusic_volume = zc_get_config(sfx_sect,"emusic",248);
345 28 pan_style = zc_get_config(sfx_sect,"pan",1);
346 // 1 <= zcmusic_bufsz <= 128
347 28 zcmusic_bufsz = vbound(zc_get_config(sfx_sect,"zcmusic_bufsz",64),1,128);
348 28 volkeys = zc_get_config(sfx_sect,"volkeys",0)!=0;
349 28 zc_vsync = zc_get_config(cfg_sect,"vsync",0);
350 28 Throttlefps = zc_get_config(cfg_sect,"throttlefps",1)!=0;
351 28 TransLayers = zc_get_config(cfg_sect,"translayers",1)!=0;
352 28 SnapshotFormat = zc_get_config(cfg_sect,"snapshot_format",3);
353 28 NameEntryMode = zc_get_config(cfg_sect,"name_entry_mode",0);
354 #ifdef __EMSCRIPTEN__
355 if (em_is_mobile()) NameEntryMode = 2;
356 #endif
357 28 ShowFPS = zc_get_config(cfg_sect,"showfps",0)!=0;
358 28 NESquit = zc_get_config(cfg_sect,"fastquit",0)!=0;
359 28 ClickToFreeze = zc_get_config(cfg_sect,"clicktofreeze",1)!=0;
360 28 title_version = zc_get_config(cfg_sect,"title",2);
361 28 abc_patternmatch = zc_get_config(cfg_sect, "lister_pattern_matching", 1);
362 28 pause_in_background = zc_get_config(cfg_sect, "pause_in_background", 0);
363
364 //default - scale x2, 640 x 480
365 28 window_width = resx = zc_get_config(cfg_sect,"window_width",640);
366 28 window_height = resy = zc_get_config(cfg_sect,"window_height",480);
367 28 SaveDragResize = zc_get_config(cfg_sect,"save_drag_resize",0)!=0;
368 28 DragAspect = zc_get_config(cfg_sect,"drag_aspect",0)!=0;
369 28 SaveWinPos = zc_get_config(cfg_sect,"save_window_position",0)!=0;
370
371 28 loadlast = zc_get_config(cfg_sect,"load_last",0);
372
373 28 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
374
375 28 zc_color_depth = (byte) zc_get_config(cfg_sect,"color_depth",8);
376
377 28 forceExit = (byte) zc_get_config(cfg_sect,"force_exit",0);
378
379 #ifdef _WIN32
380 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
381 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
382 //use_win7_keyboard_fix = (byte) zc_get_config(cfg_sect,"use_win7_key_fix",0);
383 use_win32_proc = (byte) zc_get_config(cfg_sect,"zc_win_proc_fix",0); //buggy
384
385 // This one's for Aero
386 use_dwm_flush = (byte) zc_get_config("zeldadx","use_dwm_flush",0);
387
388 // And this one fixes patches unloading on some MIDI setups
389 midi_patch_fix = (byte) zc_get_config("zeldadx","midi_patch_fix",1);
390 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
391 #else //UNIX
392 28 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
393 28 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
394 28 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
395 #endif
396 28 clearConsoleOnLoad = zc_get_config("CONSOLE","clear_console_on_load",1)!=0;
397
398 28 char const* default_path = "";
399 28 strcpy(qstdir,zc_get_config(cfg_sect,qst_dir_name,default_path));
400
401
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(strlen(qstdir)==0)
402 {
403 28 getcwd(qstdir,2048);
404 28 fix_filename_case(qstdir);
405 28 fix_filename_slashes(qstdir);
406 28 put_backslash(qstdir);
407 28 }
408 else
409 {
410 chop_path(qstdir);
411 }
412
413 28 strcpy(qstpath,qstdir); //qstpath is the local (for this run of ZC) quest path, qstdir is the universal quest dir.
414 28 ss_enable = zc_get_config(cfg_sect,"ss_enable",1) ? 1 : 0;
415 28 ss_after = vbound(zc_get_config(cfg_sect,"ss_after",14), 0, 14);
416 28 ss_speed = vbound(zc_get_config(cfg_sect,"ss_speed",2), 0, 6);
417 28 ss_density = vbound(zc_get_config(cfg_sect,"ss_density",3), 0, 6);
418 28 heart_beep = zc_get_config(cfg_sect,"heart_beep",1)!=0;
419 //gui_colorset = zc_get_config(cfg_sect,"gui_colorset",0);
420 28 sfxdat = zc_get_config(cfg_sect,"use_sfx_dat",1);
421 28 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
422 28 use_save_indicator = zc_get_config(cfg_sect,"save_indicator",0);
423 28 zc_192b163_warp_compatibility = zc_get_config(cfg_sect,"zc_192b163_warp_compatibility",0);
424 28 }
425
426 void save_control_configs(bool kb)
427 {
428 if(kb)
429 {
430 zc_set_config(ctrl_sect,"key_cheatmod_a1",cheat_modifier_keys[0]);
431 zc_set_config(ctrl_sect,"key_cheatmod_a2",cheat_modifier_keys[1]);
432 zc_set_config(ctrl_sect,"key_cheatmod_b1",cheat_modifier_keys[2]);
433 zc_set_config(ctrl_sect,"key_cheatmod_b2",cheat_modifier_keys[3]);
434
435 if (!replay_is_replaying())
436 {
437 zc_set_config(ctrl_sect,"key_a",Akey);
438 zc_set_config(ctrl_sect,"key_b",Bkey);
439 zc_set_config(ctrl_sect,"key_s",Skey);
440 zc_set_config(ctrl_sect,"key_l",Lkey);
441 zc_set_config(ctrl_sect,"key_r",Rkey);
442 zc_set_config(ctrl_sect,"key_p",Pkey);
443 zc_set_config(ctrl_sect,"key_ex1",Exkey1);
444 zc_set_config(ctrl_sect,"key_ex2",Exkey2);
445 zc_set_config(ctrl_sect,"key_ex3",Exkey3);
446 zc_set_config(ctrl_sect,"key_ex4",Exkey4);
447 zc_set_config(ctrl_sect,"key_up", DUkey);
448 zc_set_config(ctrl_sect,"key_down", DDkey);
449 zc_set_config(ctrl_sect,"key_left", DLkey);
450 zc_set_config(ctrl_sect,"key_right",DRkey);
451 }
452 }
453 else
454 {
455 zc_set_config(ctrl_sect,"joystick_index",joystick_index);
456 zc_set_config(ctrl_sect,"js_stick_1_x_stick",js_stick_1_x_stick);
457 zc_set_config(ctrl_sect,"js_stick_1_x_axis",js_stick_1_x_axis);
458 zc_set_config(ctrl_sect,"js_stick_1_x_offset",js_stick_1_x_offset ? 1 : 0);
459 zc_set_config(ctrl_sect,"js_stick_1_y_stick",js_stick_1_y_stick);
460 zc_set_config(ctrl_sect,"js_stick_1_y_axis",js_stick_1_y_axis);
461 zc_set_config(ctrl_sect,"js_stick_1_y_offset",js_stick_1_y_offset ? 1 : 0);
462 zc_set_config(ctrl_sect,"js_stick_2_x_stick",js_stick_2_x_stick);
463 zc_set_config(ctrl_sect,"js_stick_2_x_axis",js_stick_2_x_axis);
464 zc_set_config(ctrl_sect,"js_stick_2_x_offset",js_stick_2_x_offset ? 1 : 0);
465 zc_set_config(ctrl_sect,"js_stick_2_y_stick",js_stick_2_y_stick);
466 zc_set_config(ctrl_sect,"js_stick_2_y_axis",js_stick_2_y_axis);
467 zc_set_config(ctrl_sect,"js_stick_2_y_offset",js_stick_2_y_offset ? 1 : 0);
468 zc_set_config(ctrl_sect,"analog_movement",analog_movement);
469
470 zc_set_config(ctrl_sect,"btn_a",Abtn);
471 zc_set_config(ctrl_sect,"btn_b",Bbtn);
472 zc_set_config(ctrl_sect,"btn_s",Sbtn);
473 zc_set_config(ctrl_sect,"btn_m",Mbtn);
474 zc_set_config(ctrl_sect,"btn_l",Lbtn);
475 zc_set_config(ctrl_sect,"btn_r",Rbtn);
476 zc_set_config(ctrl_sect,"btn_p",Pbtn);
477 zc_set_config(ctrl_sect,"btn_ex1",Exbtn1);
478 zc_set_config(ctrl_sect,"btn_ex2",Exbtn2);
479 zc_set_config(ctrl_sect,"btn_ex3",Exbtn3);
480 zc_set_config(ctrl_sect,"btn_ex4",Exbtn4);
481
482 zc_set_config(ctrl_sect,"btn_up",DUbtn);
483 zc_set_config(ctrl_sect,"btn_down",DDbtn);
484 zc_set_config(ctrl_sect,"btn_left",DLbtn);
485 zc_set_config(ctrl_sect,"btn_right",DRbtn);
486 }
487 }
488
489 void save_game_configs()
490 {
491 packfile_password("");
492
493 zc_set_config("ZCMODULE",qst_module_name,moduledata.module_name);
494
495 if (all_get_display() && !all_get_fullscreen_flag()&& SaveWinPos)
496 {
497 int o_window_x, o_window_y;
498 al_get_window_position(all_get_display(), &o_window_x, &o_window_y);
499 zc_set_config(cfg_sect,"window_x",o_window_x);
500 zc_set_config(cfg_sect,"window_y",o_window_y);
501 }
502
503 if (all_get_display() && !all_get_fullscreen_flag() && SaveDragResize)
504 {
505 double monitor_scale = zc_get_monitor_scale();
506 window_width = al_get_display_width(all_get_display()) / monitor_scale;
507 window_height = al_get_display_height(all_get_display()) / monitor_scale;
508 zc_set_config(cfg_sect,"window_width",window_width);
509 zc_set_config(cfg_sect,"window_height",window_height);
510 }
511
512 zc_set_config(cfg_sect,"load_last",loadlast);
513 chop_path(qstdir);
514 zc_set_config(cfg_sect,qst_dir_name,qstdir);
515 zc_set_config("SAVEFILE","save_filename",save_file_name);
516 zc_set_config(cfg_sect,"use_sfx_dat",sfxdat);
517
518 flush_config_file();
519 #ifdef __EMSCRIPTEN__
520 em_sync_fs();
521 #endif
522 }
523
524 //----------------------------------------------------------------
525
526 // Timers
527
528 18631 void fps_callback()
529 {
530 18631 lastfps=framecnt;
531 18631 dword tempsecs = fps_secs;
532 18631 ++tempsecs;
533 //avgfps=((long double)avgfps*fps_secs+lastfps)/(++fps_secs); // DJGPP doesn't like this
534 18631 avgfps=((long double)avgfps*fps_secs+lastfps)/(tempsecs);
535 18631 ++fps_secs;
536 18631 framecnt=0;
537 18631 }
538
539 END_OF_FUNCTION(fps_callback)
540
541 28 int32_t Z_init_timers()
542 {
543 static bool didit = false;
544 const static char *err_str = "Couldn't allocate timer";
545 28 err_str = err_str; //Unused variable warning
546
547
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
28 if(didit)
548 return 1;
549
550 28 didit = true;
551
552 LOCK_VARIABLE(lastfps);
553 LOCK_VARIABLE(framecnt);
554 LOCK_FUNCTION(fps_callback);
555
556
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(install_int_ex(fps_callback,SECS_TO_TIMER(1)))
557 return 0;
558
559 28 return 1;
560 28 }
561
562 void Z_remove_timers()
563 {
564 remove_int(fps_callback);
565 }
566
567 //----------------------------------------------------------------
568
569 void go()
570 {
571 scare_mouse();
572 blit(screen,tmp_scr,scrx,scry,0,0,screen->w,screen->h);
573 unscare_mouse();
574 }
575
576 void comeback()
577 {
578 scare_mouse();
579 blit(tmp_scr,screen,0,0,scrx,scry,screen->w,screen->h);
580 unscare_mouse();
581 }
582
583 void dump_pal(BITMAP *dest)
584 {
585 for(int32_t i=0; i<256; i++)
586 rectfill(dest,(i&63)<<2,(i&0xFC0)>>4,((i&63)<<2)+3,((i&0xFC0)>>4)+3,i);
587 }
588
589 //----------------------------------------------------------------
590
591 //Handles converting the mouse sprite from the .dat file
592 28 void load_mouse()
593 {
594 28 system_pal();
595 28 scare_mouse();
596 28 set_mouse_sprite(NULL);
597
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 int32_t sz = vbound(int32_t(16*(is_large ? zc_get_config("zeldadx","cursor_scale_large",1.5) : zc_get_config("zeldadx","cursor_scale_small",1))),16,80);
598
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 28 times.
140 for(int32_t j = 0; j < 4; ++j)
599 {
600 112 BITMAP* tmpbmp = create_bitmap_ex(8,16,16);
601 112 BITMAP* subbmp = create_bitmap_ex(8,16,16);
602
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(zcmouse[j])
603 destroy_bitmap(zcmouse[j]);
604 112 zcmouse[j] = create_bitmap_ex(8,sz,sz);
605 112 clear_bitmap(zcmouse[j]);
606 112 clear_bitmap(tmpbmp);
607 112 clear_bitmap(subbmp);
608 112 blit((BITMAP*)datafile[BMP_MOUSE].dat,tmpbmp,1,j*17+1,0,0,16,16);
609
2/2
✓ Branch 0 taken 1792 times.
✓ Branch 1 taken 112 times.
1904 for(int32_t x = 0; x < 16; ++x)
610 {
611
2/2
✓ Branch 0 taken 28672 times.
✓ Branch 1 taken 1792 times.
30464 for(int32_t y = 0; y < 16; ++y)
612 {
613 28672 int32_t color = getpixel(tmpbmp, x, y);
614
5/5
✓ Branch 0 taken 26376 times.
✓ Branch 1 taken 532 times.
✓ Branch 2 taken 616 times.
✓ Branch 3 taken 644 times.
✓ Branch 4 taken 504 times.
28672 switch(color)
615 {
616 case dvc(1):
617 532 color = jwin_pal[jcCURSORMISC];
618 532 break;
619 case dvc(2):
620 616 color = jwin_pal[jcCURSOROUTLINE];
621 616 break;
622 case dvc(3):
623 644 color = jwin_pal[jcCURSORLIGHT];
624 644 break;
625 case dvc(5):
626 504 color = jwin_pal[jcCURSORDARK];
627 504 break;
628 }
629 28672 putpixel(subbmp, x, y, color);
630 28672 }
631 1792 }
632
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(sz!=16)
633 112 stretch_blit(subbmp, zcmouse[j], 0, 0, 16, 16, 0, 0, sz, sz);
634 else
635 blit(subbmp, zcmouse[j], 0, 0, 0, 0, 16, 16);
636 112 destroy_bitmap(tmpbmp);
637 112 destroy_bitmap(subbmp);
638 112 }
639 28 set_mouse_sprite(zcmouse[0]);
640
641 // Must attempt to show cursor for allegro 5 to render it with the associated palette.
642 28 set_palette(*hw_palette);
643 28 show_mouse(screen);
644 28 show_mouse(NULL);
645
646 28 unscare_mouse();
647 28 game_pal();
648 28 }
649
650 // sets the video mode and initializes the palette and mouse sprite
651 28 bool game_vid_mode(int32_t mode,int32_t wait)
652 {
653
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
28 if(set_gfx_mode(mode,resx,resy,0,0)!=0)
654 {
655 return false;
656 }
657
658 28 scrx = (resx-320)>>1;
659 28 scry = (resy-240)>>1;
660
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 28 times.
140 for(int32_t q = 0; q < 4; ++q)
661 112 zcmouse[q] = NULL;
662 28 load_mouse();
663 28 set_mouse_sprite(zcmouse[0]);
664
665
2/2
✓ Branch 0 taken 448 times.
✓ Branch 1 taken 28 times.
476 for(int32_t i=240; i<256; i++)
666 448 RAMpal[i]=((RGB*)datafile[PAL_GUI].dat)[i];
667
668 28 set_palette(RAMpal);
669 28 clear_to_color(screen,BLACK);
670
671 28 rest(wait);
672 28 return true;
673 28 }
674
675 4 void null_quest()
676 {
677 char qstdat_string[2048];
678 4 strcpy(qstdat_string,moduledata.datafiles[qst_dat]);
679 4 strcat(qstdat_string,"#NESQST_NEW_QST");
680
681 #ifdef __EMSCRIPTEN__
682 // The quest template data file is not included because it's really big and isn't really needed
683 // for the player, except to initialize some graphics. Those same graphics exist in this quest file,
684 // which is much smaller.
685 strcpy(qstdat_string, "modules/classic/title_gfx.dat");
686 #endif
687
688 4 byte skip_flags[4] = { 0 };
689
690 4 loadquest(qstdat_string,&QHeader,&QMisc,tunes+ZC_MIDI_COUNT,false,true,true,true,skip_flags,0,false);
691 4 }
692
693 4 void init_NES_mode()
694 {
695 /*
696 // qst.dat may not load correctly without this...
697 QHeader.templatepath[0]='\0';
698
699 if(!init_colordata(true, &QHeader, &QMisc))
700 {
701 return;
702 }
703
704 loadfullpal();
705 init_tiles(false, &QHeader);
706 */
707 4 null_quest();
708 4 }
709
710 //----------------------------------------------------------------
711
712 qword trianglelines[16]=
713 {
714 0x0000000000000000ULL,
715 0xFD00000000000000ULL,
716 0xFDFD000000000000ULL,
717 0xFDFDFD0000000000ULL,
718 0xFDFDFDFD00000000ULL,
719 0xFDFDFDFDFD000000ULL,
720 0xFDFDFDFDFDFD0000ULL,
721 0xFDFDFDFDFDFDFD00ULL,
722 0xFDFDFDFDFDFDFDFDULL,
723 0x00FDFDFDFDFDFDFDULL,
724 0x0000FDFDFDFDFDFDULL,
725 0x000000FDFDFDFDFDULL,
726 0x00000000FDFDFDFDULL,
727 0x0000000000FDFDFDULL,
728 0x000000000000FDFDULL,
729 0x00000000000000FDULL,
730 };
731
732 word screen_triangles[28][32];
733 /*
734 qword triangles[4][16]= //[direction][value]
735 {
736 {
737 0x00000000, 0x10000000, 0x21000000, 0x32100000, 0x43210000, 0x54321000, 0x65432100, 0x76543210, 0x87654321, 0x88765432, 0x88876543, 0x88887654, 0x88888765, 0x88888876, 0x88888887, 0x88888888
738 },
739 {
740 0x00000000, 0xF0000000, 0xEF000000, 0xFDF00000, 0xCFDF0000, 0xBCFDF000, 0xABCFDF00, 0x9ABCFDF0, 0x89ABCFDF, 0x889ABCFD, 0x8889ABCD, 0x88889ABC, 0x888889AB, 0x8888889A, 0x88888889, 0x88888888
741 },
742 {
743 0x00000000, 0x00000001, 0x00000012, 0x00000123, 0x00001234, 0x00012345, 0x00123456, 0x01234567, 0x12345678, 0x23456788, 0x34567888, 0x45678888, 0x56788888, 0x67888888, 0x78888888, 0x88888888
744 },
745 {
746 0x00000000, 0x0000000F, 0x000000FE, 0x00000FED, 0x0000FEDC, 0x000FEDCB, 0x00FEDCBA, 0x0FEDCBA9, 0xFEDCBA98, 0xEDCBA988, 0xDCBA9888, 0xCBA98888, 0xBA988888, 0xA9888888, 0x98888888, 0x88888888
747 }
748 };
749 */
750
751
752 /*
753 byte triangles[4][16][8]= //[direction][value][line]
754 {
755 {
756 {
757 0, 0, 0, 0, 0, 0, 0, 0
758 },
759 {
760 1, 0, 0, 0, 0, 0, 0, 0
761 },
762 {
763 2, 1, 0, 0, 0, 0, 0, 0
764 },
765 {
766 3, 2, 1, 0, 0, 0, 0, 0
767 },
768 {
769 4, 3, 2, 1, 0, 0, 0, 0
770 },
771 {
772 5, 4, 3, 2, 1, 0, 0, 0
773 },
774 {
775 6, 5, 4, 3, 2, 1, 0, 0
776 },
777 {
778 7, 6, 5, 4, 3, 2, 1, 0
779 },
780 {
781 8, 7, 6, 5, 4, 3, 2, 1
782 },
783 {
784 8, 8, 7, 6, 5, 4, 3, 2
785 },
786 {
787 8, 8, 8, 7, 6, 5, 4, 3
788 },
789 {
790 8, 8, 8, 8, 7, 6, 5, 4
791 },
792 {
793 8, 8, 8, 8, 8, 7, 6, 5
794 },
795 {
796 8, 8, 8, 8, 8, 8, 7, 6
797 },
798 {
799 8, 8, 8, 8, 8, 8, 8, 7
800 },
801 {
802 8, 8, 8, 8, 8, 8, 8, 8
803 }
804 },
805 {
806 {
807 0, 0, 0, 0, 0, 0, 0, 0
808 },
809 {
810 15, 0, 0, 0, 0, 0, 0, 0
811 },
812 {
813 14, 15, 0, 0, 0, 0, 0, 0
814 },
815 {
816 13, 14, 15, 0, 0, 0, 0, 0
817 },
818 {
819 12, 13, 14, 15, 0, 0, 0, 0
820 },
821 {
822 11, 12, 13, 14, 15, 0, 0, 0
823 },
824 {
825 10, 11, 12, 13, 14, 15, 0, 0
826 },
827 {
828 9, 10, 11, 12, 13, 14, 15, 0
829 },
830 {
831 8, 9, 10, 11, 12, 13, 14, 15
832 },
833 {
834 8, 8, 9, 10, 11, 12, 13, 14
835 },
836 {
837 8, 8, 8, 9, 10, 11, 12, 13
838 },
839 {
840 8, 8, 8, 8, 9, 10, 11, 12
841 },
842 {
843 8, 8, 8, 8, 8, 9, 10, 11
844 },
845 {
846 8, 8, 8, 8, 8, 8, 9, 10
847 },
848 {
849 8, 8, 8, 8, 8, 8, 8, 9
850 },
851 {
852 8, 8, 8, 8, 8, 8, 8, 8
853 }
854 },
855 {
856 {
857 0, 0, 0, 0, 0, 0, 0, 0
858 },
859 {
860 0, 0, 0, 0, 0, 0, 0, 1
861 },
862 {
863 0, 0, 0, 0, 0, 0, 1, 2
864 },
865 {
866 0, 0, 0, 0, 0, 1, 2, 3
867 },
868 {
869 0, 0, 0, 0, 1, 2, 3, 4
870 },
871 {
872 0, 0, 0, 1, 2, 3, 4, 5
873 },
874 {
875 0, 0, 1, 2, 3, 4, 5, 6
876 },
877 {
878 0, 1, 2, 3, 4, 5, 6, 7
879 },
880 {
881 1, 2, 3, 4, 5, 6, 7, 8
882 },
883 {
884 2, 3, 4, 5, 6, 7, 8, 8
885 },
886 {
887 3, 4, 5, 6, 7, 8, 8, 8
888 },
889 {
890 4, 5, 6, 7, 8, 8, 8, 8
891 },
892 {
893 5, 6, 7, 8, 8, 8, 8, 8
894 },
895 {
896 6, 7, 8, 8, 8, 8, 8, 8
897 },
898 {
899 7, 8, 8, 8, 8, 8, 8, 8
900 },
901 {
902 8, 8, 8, 8, 8, 8, 8, 8
903 }
904 },
905 {
906 {
907 0, 0, 0, 0, 0, 0, 0, 0
908 },
909 {
910 0, 0, 0, 0, 0, 0, 0, 15
911 },
912 {
913 0, 0, 0, 0, 0, 0, 15, 14
914 },
915 {
916 0, 0, 0, 0, 0, 15, 14, 13
917 },
918 {
919 0, 0, 0, 0, 15, 14, 13, 12
920 },
921 {
922 0, 0, 0, 15, 14, 13, 12, 11
923 },
924 {
925 0, 0, 15, 14, 13, 12, 11, 10
926 },
927 {
928 0, 15, 14, 13, 12, 11, 10, 9
929 },
930 {
931 15, 14, 13, 12, 11, 10, 9, 8
932 },
933 {
934 14, 13, 12, 11, 10, 9, 8, 8
935 },
936 {
937 13, 12, 11, 10, 9, 8, 8, 8
938 },
939 {
940 12, 11, 10, 9, 8, 8, 8, 8
941 },
942 {
943 11, 10, 9, 8, 8, 8, 8, 8
944 },
945 {
946 10, 9, 8, 8, 8, 8, 8, 8
947 },
948 {
949 9, 8, 8, 8, 8, 8, 8, 8
950 },
951 {
952 8, 8, 8, 8, 8, 8, 8, 8
953 }
954 }
955 };
956 */
957
958
959
960 /*
961 for (int32_t blockrow=0; blockrow<30; ++i)
962 {
963 for (int32_t linerow=0; linerow<8; ++i)
964 {
965 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
966 for (int32_t blockcolumn=0; blockcolumn<40; ++i)
967 {
968 triangleline=triangles[0][screen_triangles[blockrow][blockcolumn]][linerow];
969 ++triangleline;
970 }
971 }
972 }
973 */
974
975 // the ULL suffixes are to prevent this warning:
976 // warning: integer constant is too large for "int32_t" type
977
978 qword triangles[4][16][8]= //[direction][value][line]
979 {
980 {
981 {
982 0x0000000000000000ULL,
983 0x0000000000000000ULL,
984 0x0000000000000000ULL,
985 0x0000000000000000ULL,
986 0x0000000000000000ULL,
987 0x0000000000000000ULL,
988 0x0000000000000000ULL,
989 0x0000000000000000ULL
990 },
991 {
992 0xFD00000000000000ULL,
993 0x0000000000000000ULL,
994 0x0000000000000000ULL,
995 0x0000000000000000ULL,
996 0x0000000000000000ULL,
997 0x0000000000000000ULL,
998 0x0000000000000000ULL,
999 0x0000000000000000ULL
1000 },
1001 {
1002 0xFDFD000000000000ULL,
1003 0xFD00000000000000ULL,
1004 0x0000000000000000ULL,
1005 0x0000000000000000ULL,
1006 0x0000000000000000ULL,
1007 0x0000000000000000ULL,
1008 0x0000000000000000ULL,
1009 0x0000000000000000ULL
1010 },
1011 {
1012 0xFDFDFD0000000000ULL,
1013 0xFDFD000000000000ULL,
1014 0xFD00000000000000ULL,
1015 0x0000000000000000ULL,
1016 0x0000000000000000ULL,
1017 0x0000000000000000ULL,
1018 0x0000000000000000ULL,
1019 0x0000000000000000ULL
1020 },
1021 {
1022 0xFDFDFDFD00000000ULL,
1023 0xFDFDFD0000000000ULL,
1024 0xFDFD000000000000ULL,
1025 0xFD00000000000000ULL,
1026 0x0000000000000000ULL,
1027 0x0000000000000000ULL,
1028 0x0000000000000000ULL,
1029 0x0000000000000000ULL
1030 },
1031 {
1032 0xFDFDFDFDFD000000ULL,
1033 0xFDFDFDFD00000000ULL,
1034 0xFDFDFD0000000000ULL,
1035 0xFDFD000000000000ULL,
1036 0xFD00000000000000ULL,
1037 0x0000000000000000ULL,
1038 0x0000000000000000ULL,
1039 0x0000000000000000ULL
1040 },
1041 {
1042 0xFDFDFDFDFDFD0000ULL,
1043 0xFDFDFDFDFD000000ULL,
1044 0xFDFDFDFD00000000ULL,
1045 0xFDFDFD0000000000ULL,
1046 0xFDFD000000000000ULL,
1047 0xFD00000000000000ULL,
1048 0x0000000000000000ULL,
1049 0x0000000000000000ULL
1050 },
1051 {
1052 0xFDFDFDFDFDFDFD00ULL,
1053 0xFDFDFDFDFDFD0000ULL,
1054 0xFDFDFDFDFD000000ULL,
1055 0xFDFDFDFD00000000ULL,
1056 0xFDFDFD0000000000ULL,
1057 0xFDFD000000000000ULL,
1058 0xFD00000000000000ULL,
1059 0x0000000000000000ULL
1060 },
1061 {
1062 0xFDFDFDFDFDFDFDFDULL,
1063 0xFDFDFDFDFDFDFD00ULL,
1064 0xFDFDFDFDFDFD0000ULL,
1065 0xFDFDFDFDFD000000ULL,
1066 0xFDFDFDFD00000000ULL,
1067 0xFDFDFD0000000000ULL,
1068 0xFDFD000000000000ULL,
1069 0xFD00000000000000ULL
1070 },
1071 {
1072 0xFDFDFDFDFDFDFDFDULL,
1073 0xFDFDFDFDFDFDFDFDULL,
1074 0xFDFDFDFDFDFDFD00ULL,
1075 0xFDFDFDFDFDFD0000ULL,
1076 0xFDFDFDFDFD000000ULL,
1077 0xFDFDFDFD00000000ULL,
1078 0xFDFDFD0000000000ULL,
1079 0xFDFD000000000000ULL
1080 },
1081 {
1082 0xFDFDFDFDFDFDFDFDULL,
1083 0xFDFDFDFDFDFDFDFDULL,
1084 0xFDFDFDFDFDFDFDFDULL,
1085 0xFDFDFDFDFDFDFD00ULL,
1086 0xFDFDFDFDFDFD0000ULL,
1087 0xFDFDFDFDFD000000ULL,
1088 0xFDFDFDFD00000000ULL,
1089 0xFDFDFD0000000000ULL
1090 },
1091 {
1092 0xFDFDFDFDFDFDFDFDULL,
1093 0xFDFDFDFDFDFDFDFDULL,
1094 0xFDFDFDFDFDFDFDFDULL,
1095 0xFDFDFDFDFDFDFDFDULL,
1096 0xFDFDFDFDFDFDFD00ULL,
1097 0xFDFDFDFDFDFD0000ULL,
1098 0xFDFDFDFDFD000000ULL,
1099 0xFDFDFDFD00000000ULL
1100 },
1101 {
1102 0xFDFDFDFDFDFDFDFDULL,
1103 0xFDFDFDFDFDFDFDFDULL,
1104 0xFDFDFDFDFDFDFDFDULL,
1105 0xFDFDFDFDFDFDFDFDULL,
1106 0xFDFDFDFDFDFDFDFDULL,
1107 0xFDFDFDFDFDFDFD00ULL,
1108 0xFDFDFDFDFDFD0000ULL,
1109 0xFDFDFDFDFD000000ULL
1110 },
1111 {
1112 0xFDFDFDFDFDFDFDFDULL,
1113 0xFDFDFDFDFDFDFDFDULL,
1114 0xFDFDFDFDFDFDFDFDULL,
1115 0xFDFDFDFDFDFDFDFDULL,
1116 0xFDFDFDFDFDFDFDFDULL,
1117 0xFDFDFDFDFDFDFDFDULL,
1118 0xFDFDFDFDFDFDFD00ULL,
1119 0xFDFDFDFDFDFD0000ULL
1120 },
1121 {
1122 0xFDFDFDFDFDFDFDFDULL,
1123 0xFDFDFDFDFDFDFDFDULL,
1124 0xFDFDFDFDFDFDFDFDULL,
1125 0xFDFDFDFDFDFDFDFDULL,
1126 0xFDFDFDFDFDFDFDFDULL,
1127 0xFDFDFDFDFDFDFDFDULL,
1128 0xFDFDFDFDFDFDFDFDULL,
1129 0xFDFDFDFDFDFDFD00ULL
1130 },
1131 {
1132 0xFDFDFDFDFDFDFDFDULL,
1133 0xFDFDFDFDFDFDFDFDULL,
1134 0xFDFDFDFDFDFDFDFDULL,
1135 0xFDFDFDFDFDFDFDFDULL,
1136 0xFDFDFDFDFDFDFDFDULL,
1137 0xFDFDFDFDFDFDFDFDULL,
1138 0xFDFDFDFDFDFDFDFDULL,
1139 0xFDFDFDFDFDFDFDFDULL
1140 }
1141 },
1142 {
1143 {
1144 0x0000000000000000ULL,
1145 0x0000000000000000ULL,
1146 0x0000000000000000ULL,
1147 0x0000000000000000ULL,
1148 0x0000000000000000ULL,
1149 0x0000000000000000ULL,
1150 0x0000000000000000ULL,
1151 0x0000000000000000ULL
1152 },
1153 {
1154 0x00000000000000FDULL,
1155 0x0000000000000000ULL,
1156 0x0000000000000000ULL,
1157 0x0000000000000000ULL,
1158 0x0000000000000000ULL,
1159 0x0000000000000000ULL,
1160 0x0000000000000000ULL,
1161 0x0000000000000000ULL
1162 },
1163 {
1164 0x000000000000FDFDULL,
1165 0x00000000000000FDULL,
1166 0x0000000000000000ULL,
1167 0x0000000000000000ULL,
1168 0x0000000000000000ULL,
1169 0x0000000000000000ULL,
1170 0x0000000000000000ULL,
1171 0x0000000000000000ULL
1172 },
1173 {
1174 0x0000000000FDFDFDULL,
1175 0x000000000000FDFDULL,
1176 0x00000000000000FDULL,
1177 0x0000000000000000ULL,
1178 0x0000000000000000ULL,
1179 0x0000000000000000ULL,
1180 0x0000000000000000ULL,
1181 0x0000000000000000ULL
1182 },
1183 {
1184 0x00000000FDFDFDFDULL,
1185 0x0000000000FDFDFDULL,
1186 0x000000000000FDFDULL,
1187 0x00000000000000FDULL,
1188 0x0000000000000000ULL,
1189 0x0000000000000000ULL,
1190 0x0000000000000000ULL,
1191 0x0000000000000000ULL
1192 },
1193 {
1194 0x000000FDFDFDFDFDULL,
1195 0x00000000FDFDFDFDULL,
1196 0x0000000000FDFDFDULL,
1197 0x000000000000FDFDULL,
1198 0x00000000000000FDULL,
1199 0x0000000000000000ULL,
1200 0x0000000000000000ULL,
1201 0x0000000000000000ULL
1202 },
1203 {
1204 0x0000FDFDFDFDFDFDULL,
1205 0x000000FDFDFDFDFDULL,
1206 0x00000000FDFDFDFDULL,
1207 0x0000000000FDFDFDULL,
1208 0x000000000000FDFDULL,
1209 0x00000000000000FDULL,
1210 0x0000000000000000ULL,
1211 0x0000000000000000ULL
1212 },
1213 {
1214 0x00FDFDFDFDFDFDFDULL,
1215 0x0000FDFDFDFDFDFDULL,
1216 0x000000FDFDFDFDFDULL,
1217 0x00000000FDFDFDFDULL,
1218 0x0000000000FDFDFDULL,
1219 0x000000000000FDFDULL,
1220 0x00000000000000FDULL,
1221 0x0000000000000000ULL
1222 },
1223 {
1224 0xFDFDFDFDFDFDFDFDULL,
1225 0x00FDFDFDFDFDFDFDULL,
1226 0x0000FDFDFDFDFDFDULL,
1227 0x000000FDFDFDFDFDULL,
1228 0x00000000FDFDFDFDULL,
1229 0x0000000000FDFDFDULL,
1230 0x000000000000FDFDULL,
1231 0x00000000000000FDULL
1232 },
1233 {
1234 0xFDFDFDFDFDFDFDFDULL,
1235 0xFDFDFDFDFDFDFDFDULL,
1236 0x00FDFDFDFDFDFDFDULL,
1237 0x0000FDFDFDFDFDFDULL,
1238 0x000000FDFDFDFDFDULL,
1239 0x00000000FDFDFDFDULL,
1240 0x0000000000FDFDFDULL,
1241 0x000000000000FDFDULL
1242 },
1243 {
1244 0xFDFDFDFDFDFDFDFDULL,
1245 0xFDFDFDFDFDFDFDFDULL,
1246 0xFDFDFDFDFDFDFDFDULL,
1247 0x00FDFDFDFDFDFDFDULL,
1248 0x0000FDFDFDFDFDFDULL,
1249 0x000000FDFDFDFDFDULL,
1250 0x00000000FDFDFDFDULL,
1251 0x0000000000FDFDFDULL
1252 },
1253 {
1254 0xFDFDFDFDFDFDFDFDULL,
1255 0xFDFDFDFDFDFDFDFDULL,
1256 0xFDFDFDFDFDFDFDFDULL,
1257 0xFDFDFDFDFDFDFDFDULL,
1258 0x00FDFDFDFDFDFDFDULL,
1259 0x0000FDFDFDFDFDFDULL,
1260 0x000000FDFDFDFDFDULL,
1261 0x00000000FDFDFDFDULL
1262 },
1263 {
1264 0xFDFDFDFDFDFDFDFDULL,
1265 0xFDFDFDFDFDFDFDFDULL,
1266 0xFDFDFDFDFDFDFDFDULL,
1267 0xFDFDFDFDFDFDFDFDULL,
1268 0xFDFDFDFDFDFDFDFDULL,
1269 0x00FDFDFDFDFDFDFDULL,
1270 0x0000FDFDFDFDFDFDULL,
1271 0x000000FDFDFDFDFDULL
1272 },
1273 {
1274 0xFDFDFDFDFDFDFDFDULL,
1275 0xFDFDFDFDFDFDFDFDULL,
1276 0xFDFDFDFDFDFDFDFDULL,
1277 0xFDFDFDFDFDFDFDFDULL,
1278 0xFDFDFDFDFDFDFDFDULL,
1279 0xFDFDFDFDFDFDFDFDULL,
1280 0x00FDFDFDFDFDFDFDULL,
1281 0x0000FDFDFDFDFDFDULL
1282 },
1283 {
1284 0xFDFDFDFDFDFDFDFDULL,
1285 0xFDFDFDFDFDFDFDFDULL,
1286 0xFDFDFDFDFDFDFDFDULL,
1287 0xFDFDFDFDFDFDFDFDULL,
1288 0xFDFDFDFDFDFDFDFDULL,
1289 0xFDFDFDFDFDFDFDFDULL,
1290 0xFDFDFDFDFDFDFDFDULL,
1291 0x00FDFDFDFDFDFDFDULL
1292 },
1293 {
1294 0xFDFDFDFDFDFDFDFDULL,
1295 0xFDFDFDFDFDFDFDFDULL,
1296 0xFDFDFDFDFDFDFDFDULL,
1297 0xFDFDFDFDFDFDFDFDULL,
1298 0xFDFDFDFDFDFDFDFDULL,
1299 0xFDFDFDFDFDFDFDFDULL,
1300 0xFDFDFDFDFDFDFDFDULL,
1301 0xFDFDFDFDFDFDFDFDULL
1302 }
1303 },
1304 {
1305 {
1306 0x0000000000000000ULL,
1307 0x0000000000000000ULL,
1308 0x0000000000000000ULL,
1309 0x0000000000000000ULL,
1310 0x0000000000000000ULL,
1311 0x0000000000000000ULL,
1312 0x0000000000000000ULL,
1313 0x0000000000000000ULL
1314 },
1315 {
1316 0x0000000000000000ULL,
1317 0x0000000000000000ULL,
1318 0x0000000000000000ULL,
1319 0x0000000000000000ULL,
1320 0x0000000000000000ULL,
1321 0x0000000000000000ULL,
1322 0x0000000000000000ULL,
1323 0xFD00000000000000ULL
1324 },
1325 {
1326 0x0000000000000000ULL,
1327 0x0000000000000000ULL,
1328 0x0000000000000000ULL,
1329 0x0000000000000000ULL,
1330 0x0000000000000000ULL,
1331 0x0000000000000000ULL,
1332 0xFD00000000000000ULL,
1333 0xFDFD000000000000ULL
1334 },
1335 {
1336 0x0000000000000000ULL,
1337 0x0000000000000000ULL,
1338 0x0000000000000000ULL,
1339 0x0000000000000000ULL,
1340 0x0000000000000000ULL,
1341 0xFD00000000000000ULL,
1342 0xFDFD000000000000ULL,
1343 0xFDFDFD0000000000ULL
1344 },
1345 {
1346 0x0000000000000000ULL,
1347 0x0000000000000000ULL,
1348 0x0000000000000000ULL,
1349 0x0000000000000000ULL,
1350 0xFD00000000000000ULL,
1351 0xFDFD000000000000ULL,
1352 0xFDFDFD0000000000ULL,
1353 0xFDFDFDFD00000000ULL
1354 },
1355 {
1356 0x0000000000000000ULL,
1357 0x0000000000000000ULL,
1358 0x0000000000000000ULL,
1359 0xFD00000000000000ULL,
1360 0xFDFD000000000000ULL,
1361 0xFDFDFD0000000000ULL,
1362 0xFDFDFDFD00000000ULL,
1363 0xFDFDFDFDFD000000ULL
1364 },
1365 {
1366 0x0000000000000000ULL,
1367 0x0000000000000000ULL,
1368 0xFD00000000000000ULL,
1369 0xFDFD000000000000ULL,
1370 0xFDFDFD0000000000ULL,
1371 0xFDFDFDFD00000000ULL,
1372 0xFDFDFDFDFD000000ULL,
1373 0xFDFDFDFDFDFD0000ULL
1374 },
1375 {
1376 0x0000000000000000ULL,
1377 0xFD00000000000000ULL,
1378 0xFDFD000000000000ULL,
1379 0xFDFDFD0000000000ULL,
1380 0xFDFDFDFD00000000ULL,
1381 0xFDFDFDFDFD000000ULL,
1382 0xFDFDFDFDFDFD0000ULL,
1383 0xFDFDFDFDFDFDFD00ULL
1384 },
1385 {
1386 0xFD00000000000000ULL,
1387 0xFDFD000000000000ULL,
1388 0xFDFDFD0000000000ULL,
1389 0xFDFDFDFD00000000ULL,
1390 0xFDFDFDFDFD000000ULL,
1391 0xFDFDFDFDFDFD0000ULL,
1392 0xFDFDFDFDFDFDFD00ULL,
1393 0xFDFDFDFDFDFDFDFDULL
1394 },
1395 {
1396 0xFDFD000000000000ULL,
1397 0xFDFDFD0000000000ULL,
1398 0xFDFDFDFD00000000ULL,
1399 0xFDFDFDFDFD000000ULL,
1400 0xFDFDFDFDFDFD0000ULL,
1401 0xFDFDFDFDFDFDFD00ULL,
1402 0xFDFDFDFDFDFDFDFDULL,
1403 0xFDFDFDFDFDFDFDFDULL
1404 },
1405 {
1406 0xFDFDFD0000000000ULL,
1407 0xFDFDFDFD00000000ULL,
1408 0xFDFDFDFDFD000000ULL,
1409 0xFDFDFDFDFDFD0000ULL,
1410 0xFDFDFDFDFDFDFD00ULL,
1411 0xFDFDFDFDFDFDFDFDULL,
1412 0xFDFDFDFDFDFDFDFDULL,
1413 0xFDFDFDFDFDFDFDFDULL
1414 },
1415 {
1416 0xFDFDFDFD00000000ULL,
1417 0xFDFDFDFDFD000000ULL,
1418 0xFDFDFDFDFDFD0000ULL,
1419 0xFDFDFDFDFDFDFD00ULL,
1420 0xFDFDFDFDFDFDFDFDULL,
1421 0xFDFDFDFDFDFDFDFDULL,
1422 0xFDFDFDFDFDFDFDFDULL,
1423 0xFDFDFDFDFDFDFDFDULL
1424 },
1425 {
1426 0xFDFDFDFDFD000000ULL,
1427 0xFDFDFDFDFDFD0000ULL,
1428 0xFDFDFDFDFDFDFD00ULL,
1429 0xFDFDFDFDFDFDFDFDULL,
1430 0xFDFDFDFDFDFDFDFDULL,
1431 0xFDFDFDFDFDFDFDFDULL,
1432 0xFDFDFDFDFDFDFDFDULL,
1433 0xFDFDFDFDFDFDFDFDULL
1434 },
1435 {
1436 0xFDFDFDFDFDFD0000ULL,
1437 0xFDFDFDFDFDFDFD00ULL,
1438 0xFDFDFDFDFDFDFDFDULL,
1439 0xFDFDFDFDFDFDFDFDULL,
1440 0xFDFDFDFDFDFDFDFDULL,
1441 0xFDFDFDFDFDFDFDFDULL,
1442 0xFDFDFDFDFDFDFDFDULL,
1443 0xFDFDFDFDFDFDFDFDULL
1444 },
1445 {
1446 0xFDFDFDFDFDFDFD00ULL,
1447 0xFDFDFDFDFDFDFDFDULL,
1448 0xFDFDFDFDFDFDFDFDULL,
1449 0xFDFDFDFDFDFDFDFDULL,
1450 0xFDFDFDFDFDFDFDFDULL,
1451 0xFDFDFDFDFDFDFDFDULL,
1452 0xFDFDFDFDFDFDFDFDULL,
1453 0xFDFDFDFDFDFDFDFDULL
1454 },
1455 {
1456 0xFDFDFDFDFDFDFDFDULL,
1457 0xFDFDFDFDFDFDFDFDULL,
1458 0xFDFDFDFDFDFDFDFDULL,
1459 0xFDFDFDFDFDFDFDFDULL,
1460 0xFDFDFDFDFDFDFDFDULL,
1461 0xFDFDFDFDFDFDFDFDULL,
1462 0xFDFDFDFDFDFDFDFDULL,
1463 0xFDFDFDFDFDFDFDFDULL
1464 }
1465 },
1466 {
1467 {
1468 0x0000000000000000ULL,
1469 0x0000000000000000ULL,
1470 0x0000000000000000ULL,
1471 0x0000000000000000ULL,
1472 0x0000000000000000ULL,
1473 0x0000000000000000ULL,
1474 0x0000000000000000ULL,
1475 0x0000000000000000ULL
1476 },
1477 {
1478 0x0000000000000000ULL,
1479 0x0000000000000000ULL,
1480 0x0000000000000000ULL,
1481 0x0000000000000000ULL,
1482 0x0000000000000000ULL,
1483 0x0000000000000000ULL,
1484 0x0000000000000000ULL,
1485 0x00000000000000FDULL
1486 },
1487 {
1488 0x0000000000000000ULL,
1489 0x0000000000000000ULL,
1490 0x0000000000000000ULL,
1491 0x0000000000000000ULL,
1492 0x0000000000000000ULL,
1493 0x0000000000000000ULL,
1494 0x00000000000000FDULL,
1495 0x000000000000FDFDULL
1496 },
1497 {
1498 0x0000000000000000ULL,
1499 0x0000000000000000ULL,
1500 0x0000000000000000ULL,
1501 0x0000000000000000ULL,
1502 0x0000000000000000ULL,
1503 0x00000000000000FDULL,
1504 0x000000000000FDFDULL,
1505 0x0000000000FDFDFDULL
1506 },
1507 {
1508 0x0000000000000000ULL,
1509 0x0000000000000000ULL,
1510 0x0000000000000000ULL,
1511 0x0000000000000000ULL,
1512 0x00000000000000FDULL,
1513 0x000000000000FDFDULL,
1514 0x0000000000FDFDFDULL,
1515 0x00000000FDFDFDFDULL
1516 },
1517 {
1518 0x0000000000000000ULL,
1519 0x0000000000000000ULL,
1520 0x0000000000000000ULL,
1521 0x00000000000000FDULL,
1522 0x000000000000FDFDULL,
1523 0x0000000000FDFDFDULL,
1524 0x00000000FDFDFDFDULL,
1525 0x000000FDFDFDFDFDULL
1526 },
1527 {
1528 0x0000000000000000ULL,
1529 0x0000000000000000ULL,
1530 0x00000000000000FDULL,
1531 0x000000000000FDFDULL,
1532 0x0000000000FDFDFDULL,
1533 0x00000000FDFDFDFDULL,
1534 0x000000FDFDFDFDFDULL,
1535 0x0000FDFDFDFDFDFDULL
1536 },
1537 {
1538 0x0000000000000000ULL,
1539 0x00000000000000FDULL,
1540 0x000000000000FDFDULL,
1541 0x0000000000FDFDFDULL,
1542 0x00000000FDFDFDFDULL,
1543 0x000000FDFDFDFDFDULL,
1544 0x0000FDFDFDFDFDFDULL,
1545 0x00FDFDFDFDFDFDFDULL
1546 },
1547 {
1548 0x00000000000000FDULL,
1549 0x000000000000FDFDULL,
1550 0x0000000000FDFDFDULL,
1551 0x00000000FDFDFDFDULL,
1552 0x000000FDFDFDFDFDULL,
1553 0x0000FDFDFDFDFDFDULL,
1554 0x00FDFDFDFDFDFDFDULL,
1555 0xFDFDFDFDFDFDFDFDULL
1556 },
1557 {
1558 0x000000000000FDFDULL,
1559 0x0000000000FDFDFDULL,
1560 0x00000000FDFDFDFDULL,
1561 0x000000FDFDFDFDFDULL,
1562 0x0000FDFDFDFDFDFDULL,
1563 0x00FDFDFDFDFDFDFDULL,
1564 0xFDFDFDFDFDFDFDFDULL,
1565 0xFDFDFDFDFDFDFDFDULL
1566 },
1567 {
1568 0x0000000000FDFDFDULL,
1569 0x00000000FDFDFDFDULL,
1570 0x000000FDFDFDFDFDULL,
1571 0x0000FDFDFDFDFDFDULL,
1572 0x00FDFDFDFDFDFDFDULL,
1573 0xFDFDFDFDFDFDFDFDULL,
1574 0xFDFDFDFDFDFDFDFDULL,
1575 0xFDFDFDFDFDFDFDFDULL
1576 },
1577 {
1578 0x00000000FDFDFDFDULL,
1579 0x000000FDFDFDFDFDULL,
1580 0x0000FDFDFDFDFDFDULL,
1581 0x00FDFDFDFDFDFDFDULL,
1582 0xFDFDFDFDFDFDFDFDULL,
1583 0xFDFDFDFDFDFDFDFDULL,
1584 0xFDFDFDFDFDFDFDFDULL,
1585 0xFDFDFDFDFDFDFDFDULL
1586 },
1587 {
1588 0x000000FDFDFDFDFDULL,
1589 0x0000FDFDFDFDFDFDULL,
1590 0x00FDFDFDFDFDFDFDULL,
1591 0xFDFDFDFDFDFDFDFDULL,
1592 0xFDFDFDFDFDFDFDFDULL,
1593 0xFDFDFDFDFDFDFDFDULL,
1594 0xFDFDFDFDFDFDFDFDULL,
1595 0xFDFDFDFDFDFDFDFDULL
1596 },
1597 {
1598 0x0000FDFDFDFDFDFDULL,
1599 0x00FDFDFDFDFDFDFDULL,
1600 0xFDFDFDFDFDFDFDFDULL,
1601 0xFDFDFDFDFDFDFDFDULL,
1602 0xFDFDFDFDFDFDFDFDULL,
1603 0xFDFDFDFDFDFDFDFDULL,
1604 0xFDFDFDFDFDFDFDFDULL,
1605 0xFDFDFDFDFDFDFDFDULL
1606 },
1607 {
1608 0x00FDFDFDFDFDFDFDULL,
1609 0xFDFDFDFDFDFDFDFDULL,
1610 0xFDFDFDFDFDFDFDFDULL,
1611 0xFDFDFDFDFDFDFDFDULL,
1612 0xFDFDFDFDFDFDFDFDULL,
1613 0xFDFDFDFDFDFDFDFDULL,
1614 0xFDFDFDFDFDFDFDFDULL,
1615 0xFDFDFDFDFDFDFDFDULL
1616 },
1617 {
1618 0xFDFDFDFDFDFDFDFDULL,
1619 0xFDFDFDFDFDFDFDFDULL,
1620 0xFDFDFDFDFDFDFDFDULL,
1621 0xFDFDFDFDFDFDFDFDULL,
1622 0xFDFDFDFDFDFDFDFDULL,
1623 0xFDFDFDFDFDFDFDFDULL,
1624 0xFDFDFDFDFDFDFDFDULL,
1625 0xFDFDFDFDFDFDFDFDULL
1626 }
1627 }
1628 };
1629
1630 int32_t black_opening_count=0;
1631 int32_t black_opening_x,black_opening_y;
1632 int32_t black_opening_shape;
1633
1634 484 int32_t choose_opening_shape()
1635 {
1636 // First, count how many bits are set
1637 484 int32_t numBits=0;
1638 int32_t bitCounter;
1639
1640
2/2
✓ Branch 0 taken 2420 times.
✓ Branch 1 taken 484 times.
2904 for(int32_t i=0; i<bosMAX; i++)
1641 {
1642
2/2
✓ Branch 0 taken 1720 times.
✓ Branch 1 taken 700 times.
2420 if(COOLSCROLL&(1<<i))
1643 700 numBits++;
1644 2420 }
1645
1646 // Shouldn't happen...
1647
1/2
✓ Branch 0 taken 484 times.
✗ Branch 1 not taken.
484 if(numBits==0)
1648 return bosCIRCLE;
1649
1650 // Pick a bit
1651 484 bitCounter=zc_rand()%numBits+1;
1652
1653
2/2
✓ Branch 0 taken 696 times.
✓ Branch 1 taken 26 times.
722 for(int32_t i=0; i<bosMAX; i++)
1654 {
1655 // If this bit is set, decrement the bit counter
1656
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 614 times.
696 if(COOLSCROLL&(1<<i))
1657 614 bitCounter--;
1658
1659 // When the counter hits 0, return a value based on
1660 // which bit it stopped on.
1661 // Reminder: enum {bosCIRCLE=0, bosOVAL, bosTRIANGLE, bosSMAS, bosFADEBLACK, bosMAX};
1662
2/2
✓ Branch 0 taken 458 times.
✓ Branch 1 taken 238 times.
696 if(bitCounter==0)
1663 458 return i;
1664 238 }
1665
1666 // Shouldn't be necessary, but the compiler might complain, at least
1667 26 return bosCIRCLE;
1668 484 }
1669
1670 140 void close_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1671 {
1672
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1673
1674 140 int32_t w=256, h=224;
1675 140 int32_t blockrows=28, blockcolumns=32;
1676 140 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1677
1678
2/2
✓ Branch 0 taken 3920 times.
✓ Branch 1 taken 140 times.
4060 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1679 {
1680
2/2
✓ Branch 0 taken 125440 times.
✓ Branch 1 taken 3920 times.
129360 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1681 {
1682
2/2
✓ Branch 0 taken 67190 times.
✓ Branch 1 taken 58250 times.
125440 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1683 125440 }
1684 3920 }
1685
1686 140 black_opening_count = 66;
1687 140 black_opening_x = x;
1688 140 black_opening_y = y;
1689 140 lensclk = 0;
1690 //black_opening_shape=(black_opening_shape+1)%bosMAX;
1691
1692
1693
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(black_opening_shape == bosFADEBLACK)
1694 {
1695 refreshTints();
1696 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1697 }
1698
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(wait)
1699 {
1700 FFCore.warpScriptCheck();
1701 for(int32_t i=0; i<66; i++)
1702 {
1703 draw_screen(tmpscr);
1704 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1705 advanceframe(true);
1706
1707 if(Quit)
1708 {
1709 break;
1710 }
1711 }
1712 }
1713 140 }
1714
1715 344 void open_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1716 {
1717
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 344 times.
344 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1718
1719 344 int32_t w=256, h=224;
1720 344 int32_t blockrows=28, blockcolumns=32;
1721 344 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1722
1723
2/2
✓ Branch 0 taken 9632 times.
✓ Branch 1 taken 344 times.
9976 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1724 {
1725
2/2
✓ Branch 0 taken 308224 times.
✓ Branch 1 taken 9632 times.
317856 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1726 {
1727
2/2
✓ Branch 0 taken 148149 times.
✓ Branch 1 taken 160075 times.
308224 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1728 308224 }
1729 9632 }
1730
1731 344 black_opening_count = -66;
1732 344 black_opening_x = x;
1733 344 black_opening_y = y;
1734 344 lensclk = 0;
1735
1/2
✓ Branch 0 taken 344 times.
✗ Branch 1 not taken.
344 if(black_opening_shape == bosFADEBLACK)
1736 {
1737 refreshTints();
1738 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1739 }
1740
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 234 times.
344 if(wait)
1741 {
1742 234 FFCore.warpScriptCheck();
1743
2/2
✓ Branch 0 taken 234 times.
✓ Branch 1 taken 15444 times.
15678 for(int32_t i=0; i<66; i++)
1744 {
1745 15444 draw_screen(tmpscr);
1746 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1747 15444 advanceframe(true);
1748
1749
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15444 times.
15444 if(Quit)
1750 {
1751 break;
1752 }
1753 15444 }
1754 234 }
1755 344 }
1756
1757 31944 void black_opening(BITMAP *dest,int32_t x,int32_t y,int32_t a,int32_t max_a)
1758 {
1759 31944 clear_to_color(tmp_scr,BLACK);
1760 31944 int32_t w=256, h=224;
1761
1762
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 858 times.
✓ Branch 2 taken 660 times.
✓ Branch 3 taken 1650 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 28776 times.
31944 switch(black_opening_shape)
1763 {
1764 case bosOVAL:
1765 {
1766 858 double new_w=(w/2)+abs(w/2-x);
1767 858 double new_h=(h/2)+abs(h/2-y);
1768 858 double b=sqrt(((new_w*new_w)/4)+(new_h*new_h));
1769 858 ellipsefill(tmp_scr,x,y,int32_t(2*a*b/max_a)/8*8,int32_t(a*b/max_a)/8*8,0);
1770 858 break;
1771 }
1772
1773 case bosTRIANGLE:
1774 {
1775 660 double new_w=(w/2)+abs(w/2-x);
1776 660 double new_h=(h/2)+abs(h/2-y);
1777 660 double r=a*(new_w*sqrt((double)3)+new_h)/max_a;
1778 660 double P2= (PI/2);
1779 660 double P23=(2*PI/3);
1780 660 double P43=(4*PI/3);
1781 660 double Pa= (-4*PI*a/(3*max_a));
1782 660 double angle=P2+Pa;
1783 660 double a0=angle;
1784 660 double a2=angle+P23;
1785 660 double a4=angle+P43;
1786 1320 triangle(tmp_scr, x+int32_t(zc::math::Cos(a0)*r), y-int32_t(zc::math::Sin(a0)*r),
1787 660 x+int32_t(zc::math::Cos(a2)*r), y-int32_t(zc::math::Sin(a2)*r),
1788 660 x+int32_t(zc::math::Cos(a4)*r), y-int32_t(zc::math::Sin(a4)*r),
1789 0);
1790 660 break;
1791 }
1792
1793 case bosSMAS:
1794 {
1795
2/2
✓ Branch 0 taken 660 times.
✓ Branch 1 taken 990 times.
1650 int32_t distance=zc_max(abs(w/2-x),abs(h/2-y))/8;
1796
1797
2/2
✓ Branch 0 taken 46200 times.
✓ Branch 1 taken 1650 times.
47850 for(int32_t blockrow=0; blockrow<28; ++blockrow) //30
1798 {
1799
2/2
✓ Branch 0 taken 369600 times.
✓ Branch 1 taken 46200 times.
415800 for(int32_t linerow=0; linerow<8; ++linerow)
1800 {
1801 369600 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1802
1803
2/2
✓ Branch 0 taken 11827200 times.
✓ Branch 1 taken 369600 times.
12196800 for(int32_t blockcolumn=0; blockcolumn<32; ++blockcolumn) //40
1804 {
1805 35481600 *triangleline=triangles[(screen_triangles[blockrow][blockcolumn]&0xC000)>>14]
1806
6/6
✓ Branch 0 taken 8249728 times.
✓ Branch 1 taken 3577472 times.
✓ Branch 2 taken 7829672 times.
✓ Branch 3 taken 3997528 times.
✓ Branch 4 taken 4252200 times.
✓ Branch 5 taken 3577472 times.
11827200 [zc_min(zc_max((((31+distance)*(max_a-a)/max_a)+((screen_triangles[blockrow][blockcolumn]&0x0FFF)-0x0100)-(15+distance)),0),15)]
1807 11827200 [linerow];
1808 11827200 ++triangleline;
1809
1810
2/2
✓ Branch 0 taken 10348800 times.
✓ Branch 1 taken 1478400 times.
11827200 if(linerow==0)
1811 {
1812 1478400 }
1813 11827200 }
1814 369600 }
1815 46200 }
1816
1817 1650 break;
1818 }
1819
1820 case bosFADEBLACK:
1821 {
1822 if(black_opening_count<0)
1823 {
1824 black_fade(zc_min(-black_opening_count,63));
1825 }
1826 else if(black_opening_count>0)
1827 {
1828 black_fade(63-zc_max(black_opening_count-3,0));
1829 }
1830 else black_fade(0);
1831 return; //no blitting from tmp_scr!
1832 }
1833
1834 28776 case bosCIRCLE:
1835 default:
1836 {
1837 28776 double new_w=(w/2)+abs(w/2-x);
1838 28776 double new_h=(h/2)+abs(h/2-y);
1839 28776 int32_t r=int32_t(sqrt((new_w*new_w)+(new_h*new_h))*a/max_a);
1840 //circlefill(tmp_scr,x,y,a<<3,0);
1841 28776 circlefill(tmp_scr,x,y,r,0);
1842 28776 break;
1843 }
1844 }
1845
1846 31944 masked_blit(tmp_scr,dest,0,0,0,0,320,240);
1847 31944 }
1848
1849
1850 void black_fade(int32_t fadeamnt)
1851 {
1852 for(int32_t i=0; i < 0xEF; i++)
1853 {
1854 RAMpal[i].r = vbound(tempblackpal[i].r-fadeamnt,0,63);
1855 RAMpal[i].g = vbound(tempblackpal[i].g-fadeamnt,0,63);
1856 RAMpal[i].b = vbound(tempblackpal[i].b-fadeamnt,0,63);
1857 }
1858
1859 refreshpal = true;
1860 }
1861
1862 //----------------------------------------------------------------
1863
1864 12584867 bool item_disabled(int32_t item) //is this item disabled?
1865 {
1866
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12584867 times.
12584867 return (item>=0 && game->items_off[item] != 0);
1867 }
1868
1869 4055993 bool can_use_item(int32_t item_type, int32_t item) //can Hero use this item?
1870 {
1871
2/2
✓ Branch 0 taken 57842 times.
✓ Branch 1 taken 3998151 times.
4055993 if(current_item(item_type, true) >=item)
1872 {
1873 57842 return true;
1874 }
1875
1876 3998151 return false;
1877 4055993 }
1878
1879 16882319 bool has_item(int32_t item_type, int32_t it) //does Hero possess this item?
1880 {
1881
5/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 3042842 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1857470 times.
✓ Branch 6 taken 9035160 times.
✓ Branch 7 taken 2925848 times.
✓ Branch 8 taken 20999 times.
16882319 switch(item_type)
1882 {
1883 case itype_bomb:
1884 case itype_sbomb:
1885 {
1886 int32_t itemid = getItemID(itemsbuf, item_type, it);
1887
1888 if(itemid == -1)
1889 return false;
1890
1891 return (game->get_item(itemid));
1892 }
1893
1894 case itype_clock:
1895 {
1896 3042842 int32_t itemid = getItemID(itemsbuf, item_type, it);
1897
1898
2/4
✓ Branch 0 taken 3042842 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3042842 times.
✗ Branch 3 not taken.
3042842 if(itemid != -1 && (itemsbuf[itemid].flags & ITEM_FLAG1)) //Active clock
1899 return (game->get_item(itemid));
1900 3042842 return Hero.getClock()?1:0;
1901 }
1902
1903 case itype_key:
1904 return (game->get_keys()>0);
1905
1906 case itype_magiccontainer:
1907 return (game->get_maxmagic()>=game->get_mp_per_block());
1908
1909 case itype_triforcepiece: //it: -2=any, -1=current level, other=that level
1910 {
1911
1/3
✓ Branch 0 taken 1857470 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
1857470 switch(it)
1912 {
1913 case -2:
1914 {
1915 for(int32_t i=0; i<MAXLEVELS; i++)
1916 {
1917 if(game->lvlitems[i]&liTRIFORCE)
1918 {
1919 return true;
1920 }
1921 }
1922
1923 return false;
1924 }
1925
1926 case -1:
1927 return (game->lvlitems[dlevel]&liTRIFORCE);
1928
1929 default:
1930
2/4
✓ Branch 0 taken 1857470 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1857470 times.
1857470 if(it>=0&&it<MAXLEVELS)
1931 {
1932 1857470 return (game->lvlitems[it]&liTRIFORCE);
1933 }
1934
1935 break;
1936 }
1937
1938 return 0;
1939 }
1940
1941 case itype_map: //it: -2=any, -1=current level, other=that level
1942 {
1943
1/3
✓ Branch 0 taken 9035160 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
9035160 switch(it)
1944 {
1945 case -2:
1946 {
1947 for(int32_t i=0; i<MAXLEVELS; i++)
1948 {
1949 if(game->lvlitems[i]&liMAP)
1950 {
1951 return true;
1952 }
1953 }
1954
1955 return false;
1956 }
1957
1958 case -1:
1959 return (game->lvlitems[dlevel]&liMAP)!=0;
1960
1961 default:
1962
2/4
✓ Branch 0 taken 9035160 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9035160 times.
9035160 if(it>=0&&it<MAXLEVELS)
1963 {
1964 9035160 return (game->lvlitems[it]&liMAP)!=0;
1965 }
1966
1967 break;
1968 }
1969
1970 return 0;
1971 }
1972
1973 case itype_compass: //it: -2=any, -1=current level, other=that level
1974 {
1975
1/3
✓ Branch 0 taken 2925848 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
2925848 switch(it)
1976 {
1977 case -2:
1978 {
1979 for(int32_t i=0; i<MAXLEVELS; i++)
1980 {
1981 if(game->lvlitems[i]&liCOMPASS)
1982 {
1983 return true;
1984 }
1985 }
1986
1987 return false;
1988 }
1989
1990 case -1:
1991 return (game->lvlitems[dlevel]&liCOMPASS)!=0;
1992
1993 default:
1994
2/4
✓ Branch 0 taken 2925848 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2925848 times.
✗ Branch 3 not taken.
2925848 if(it>=0&&it<MAXLEVELS)
1995 {
1996 2925848 return (game->lvlitems[it]&liCOMPASS)!=0;
1997 }
1998
1999 break;
2000 }
2001 return 0;
2002 }
2003
2004 case itype_bosskey: //it: -2=any, -1=current level, other=that level
2005 {
2006
1/3
✓ Branch 0 taken 20999 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
20999 switch(it)
2007 {
2008 case -2:
2009 {
2010 for(int32_t i=0; i<MAXLEVELS; i++)
2011 {
2012 if(game->lvlitems[i]&liBOSSKEY)
2013 {
2014 return true;
2015 }
2016 }
2017
2018 return false;
2019 }
2020
2021 case -1:
2022 return (game->lvlitems[dlevel]&liBOSSKEY)?1:0;
2023
2024 default:
2025
2/4
✓ Branch 0 taken 20999 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 20999 times.
20999 if(it>=0&&it<MAXLEVELS)
2026 {
2027 20999 return (game->lvlitems[it]&liBOSSKEY)?1:0;
2028 }
2029 break;
2030 }
2031 return 0;
2032 }
2033
2034 default:
2035 //it=(1<<(it-1));
2036 /*if (item_type>=itype_max)
2037 {
2038 system_pal();
2039 jwin_alert("Error","has_item exception",NULL,NULL,"O&K",NULL,'k',0,lfont);
2040 game_pal();
2041
2042 return false;
2043 }*/
2044 int32_t itemid = getItemID(itemsbuf, item_type, it);
2045
2046 if(itemid == -1)
2047 return false;
2048
2049 return game->get_item(itemid);
2050 }
2051 16882319 }
2052
2053
2054 51785784 int32_t current_item(int32_t item_type, bool checkenabled) //item currently being used
2055 {
2056
9/9
✓ Branch 0 taken 3042842 times.
✓ Branch 1 taken 27443048 times.
✓ Branch 2 taken 3042842 times.
✓ Branch 3 taken 3042842 times.
✓ Branch 4 taken 3042842 times.
✓ Branch 5 taken 3042842 times.
✓ Branch 6 taken 3042842 times.
✓ Branch 7 taken 3042842 times.
✓ Branch 8 taken 3042842 times.
51785784 switch(item_type)
2057 {
2058 case itype_clock:
2059 {
2060 3042842 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2061
2062
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3042842 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3042842 if(maxid != -1 && (itemsbuf[maxid].flags & ITEM_FLAG1)) //Active clock
2063 return itemsbuf[maxid].fam_type;
2064
2065 3042842 return has_item(itype_clock,1) ? 1 : 0;
2066 }
2067
2068 case itype_key:
2069 3042842 return game->get_keys();
2070
2071 case itype_lkey:
2072 3042842 return game->lvlkeys[get_dlevel()];
2073
2074 case itype_magiccontainer:
2075 3042842 return game->get_maxmagic()/game->get_mp_per_block();
2076
2077 case itype_triforcepiece:
2078 {
2079 3042842 int32_t count=0;
2080
2081
2/2
✓ Branch 0 taken 1557935104 times.
✓ Branch 1 taken 3042842 times.
1560977946 for(int32_t i=0; i<MAXLEVELS; i++)
2082 {
2083 1557935104 count+=(game->lvlitems[i]&liTRIFORCE)?1:0;
2084 1557935104 }
2085
2086 3042842 return count;
2087 }
2088
2089 case itype_map:
2090 {
2091 3042842 int32_t count=0;
2092
2093
2/2
✓ Branch 0 taken 1557935104 times.
✓ Branch 1 taken 3042842 times.
1560977946 for(int32_t i=0; i<MAXLEVELS; i++)
2094 {
2095 1557935104 count+=(game->lvlitems[i]&liMAP)?1:0;
2096 1557935104 }
2097
2098 3042842 return count;
2099 }
2100
2101 case itype_compass:
2102 {
2103 3042842 int32_t count=0;
2104
2105
2/2
✓ Branch 0 taken 1557935104 times.
✓ Branch 1 taken 3042842 times.
1560977946 for(int32_t i=0; i<MAXLEVELS; i++)
2106 {
2107 1557935104 count+=(game->lvlitems[i]&liCOMPASS)?1:0;
2108 1557935104 }
2109
2110 3042842 return count;
2111 }
2112
2113 case itype_bosskey:
2114 {
2115 3042842 int32_t count=0;
2116
2117
2/2
✓ Branch 0 taken 1557935104 times.
✓ Branch 1 taken 3042842 times.
1560977946 for(int32_t i=0; i<MAXLEVELS; i++)
2118 {
2119 1557935104 count+=(game->lvlitems[i]&liBOSSKEY)?1:0;
2120 1557935104 }
2121
2122 3042842 return count;
2123 }
2124
2125 default:
2126 27443048 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2127
2128
2/2
✓ Branch 0 taken 5849832 times.
✓ Branch 1 taken 21593216 times.
27443048 if(maxid == -1)
2129 21593216 return 0;
2130
2131 5849832 return itemsbuf[maxid].fam_type;
2132 }
2133 51785784 }
2134
2135 47729791 int32_t current_item(int32_t item_type) //item currently being used
2136 {
2137 47729791 return current_item(item_type, true);
2138 }
2139
2140 28 std::map<int32_t, int32_t> itemcache;
2141
2142 // Not actually used by anything at the moment...
2143 void removeFromItemCache(int32_t itemid)
2144 {
2145 itemcache.erase(itemid);
2146 }
2147
2148 14211 void flushItemCache()
2149 {
2150 14211 itemcache.clear();
2151
2152 //also fix the active subscreen if items were deleted -DD
2153
1/2
✓ Branch 0 taken 14211 times.
✗ Branch 1 not taken.
14211 if(game != NULL)
2154 {
2155 14211 verifyBothWeapons();
2156 14211 load_Sitems(&QMisc);
2157 14211 }
2158 14211 }
2159
2160 // This is used often, so it should be as direct as possible.
2161 1705007344 int32_t _c_item_id_internal(int32_t itemtype, bool checkmagic, bool jinx_check)
2162 {
2163
2/2
✓ Branch 0 taken 1666686329 times.
✓ Branch 1 taken 38321015 times.
1705007344 if(jinx_check)
2164 {
2165
4/4
✓ Branch 0 taken 23802462 times.
✓ Branch 1 taken 14518553 times.
✓ Branch 2 taken 20395436 times.
✓ Branch 3 taken 3407026 times.
38321015 if(!(HeroSwordClk() || HeroItemClk()))
2166 20395436 jinx_check = false; //not jinxed
2167 38321015 }
2168
4/4
✓ Branch 0 taken 1687930273 times.
✓ Branch 1 taken 17077071 times.
✓ Branch 2 taken 17787258 times.
✓ Branch 3 taken 1670143015 times.
1705007344 if(itemtype!=itype_ring && !jinx_check) // Rings must always be checked, as must jinx checks...
2169 {
2170 1670143015 std::map<int32_t,int32_t>::iterator res = itemcache.find(itemtype);
2171
2172
2/2
✓ Branch 0 taken 1662889395 times.
✓ Branch 1 taken 7253620 times.
1670143015 if(res != itemcache.end())
2173 1662889395 return res->second;
2174 7253620 }
2175
2176 42117949 int32_t result = -1;
2177 42117949 int32_t highestlevel = -1;
2178
2179
2/2
✓ Branch 0 taken 10782194944 times.
✓ Branch 1 taken 42117949 times.
10824312893 for(int32_t i=0; i<MAXITEMS; i++)
2180 {
2181
5/6
✓ Branch 0 taken 839070580 times.
✓ Branch 1 taken 9943124364 times.
✓ Branch 2 taken 12110143 times.
✓ Branch 3 taken 826960437 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 12110143 times.
10782194944 if(game->get_item(i) && itemsbuf[i].family==itemtype && !item_disabled(i))
2182 {
2183
4/4
✓ Branch 0 taken 3090127 times.
✓ Branch 1 taken 9020016 times.
✓ Branch 2 taken 954641 times.
✓ Branch 3 taken 11155502 times.
12110143 if((checkmagic || itemtype == itype_ring) && itemtype != itype_magicring)
2184 {
2185 //printf("Checkmagic for %d: %d (%d %d)\n",i,checkmagiccost(i),itemsbuf[i].magic*game->get_magicdrainrate(),game->get_magic());
2186
2/2
✓ Branch 0 taken 11155382 times.
✓ Branch 1 taken 120 times.
11155502 if(!checkmagiccost(i))
2187 {
2188
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 108 times.
120 if ( !get_bit(quest_rules,qr_NEVERDISABLEAMMOONSUBSCREEN) ) continue; //don't make items with a magic cost vanish!! -Z
2189 12 }
2190 11155394 }
2191
6/6
✓ Branch 0 taken 10275202 times.
✓ Branch 1 taken 1834833 times.
✓ Branch 2 taken 181578 times.
✓ Branch 3 taken 1653255 times.
✓ Branch 4 taken 1165337 times.
✓ Branch 5 taken 669496 times.
12110035 if(jinx_check && (usesSwordJinx(i) ? HeroSwordClk() : HeroItemClk()))
2192 {
2193
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 669496 times.
669496 if(!(itemsbuf[i].flags & ITEM_JINX_IMMUNE))
2194 669496 continue;
2195 }
2196
2197
2/2
✓ Branch 0 taken 178745 times.
✓ Branch 1 taken 11261794 times.
11440539 if(itemsbuf[i].fam_type >= highestlevel)
2198 {
2199 11261794 highestlevel = itemsbuf[i].fam_type;
2200 11261794 result=i;
2201 11261794 }
2202 11440539 }
2203 10781525340 }
2204
2205
2/2
✓ Branch 0 taken 17925579 times.
✓ Branch 1 taken 24192370 times.
42117949 if(!jinx_check) //Can't cache jinx_check results
2206 24192370 itemcache[itemtype] = result;
2207 42117949 return result;
2208 1705007344 }
2209
2210 // 'jinx_check' indicates that the highest level item *immune to jinxes* should be returned.
2211 1687322780 int32_t current_item_id(int32_t itemtype, bool checkmagic, bool jinx_check)
2212 {
2213 1687322780 auto ret = _c_item_id_internal(itemtype,checkmagic,jinx_check);
2214
2/2
✓ Branch 0 taken 20636451 times.
✓ Branch 1 taken 1666686329 times.
1687322780 if(!jinx_check) //If not already a jinx-immune-only check...
2215 {
2216 //And the player IS jinxed...
2217
4/4
✓ Branch 0 taken 1652359129 times.
✓ Branch 1 taken 14327200 times.
✓ Branch 2 taken 3357364 times.
✓ Branch 3 taken 1649001765 times.
1666686329 if(HeroSwordClk() || HeroItemClk())
2218 {
2219 //Then do a jinx-immune-only check here
2220 17684564 auto ret2 = _c_item_id_internal(itemtype,checkmagic,true);
2221 //And *IF IT FINDS A VALID ITEM*, return that one instead! -Em
2222 //Should NOT need a compat rule, as this should always return -1 in old quests.
2223
2/2
✓ Branch 0 taken 799716 times.
✓ Branch 1 taken 16884848 times.
17684564 if(ret2 > -1) return ret2;
2224 16884848 }
2225 1665886613 }
2226 1686523064 return ret;
2227 1687322780 }
2228 11378378 int32_t current_item_power(int32_t itemtype)
2229 {
2230 11378378 int32_t result = current_item_id(itemtype,true);
2231
2/2
✓ Branch 0 taken 8098941 times.
✓ Branch 1 taken 3279437 times.
11378378 return (result<0) ? 0 : itemsbuf[result].power;
2232 }
2233
2234 5 int32_t heart_container_id()
2235 {
2236
1/2
✓ Branch 0 taken 145 times.
✗ Branch 1 not taken.
145 for(int32_t i=0; i<MAXITEMS; i++)
2237 {
2238
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 140 times.
145 if(itemsbuf[i].family == itype_heartcontainer)
2239 {
2240 5 return i;
2241 }
2242 140 }
2243 return -1;
2244 5 }
2245
2246 3042842 int32_t item_tile_mod()
2247 {
2248 3042842 int32_t tile=0;
2249
2250
2/2
✓ Branch 0 taken 930334 times.
✓ Branch 1 taken 2112508 times.
3042842 if(game->get_bombs())
2251 {
2252 2112508 int32_t itemid = current_item_id(itype_bomb,false);
2253
3/4
✓ Branch 0 taken 2031449 times.
✓ Branch 1 taken 81059 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2031449 times.
2112508 if(itemid > -1 && checkbunny(itemid))
2254 2031449 tile+=itemsbuf[itemid].ltm;
2255 2112508 }
2256
2257
2/2
✓ Branch 0 taken 2604053 times.
✓ Branch 1 taken 438789 times.
3042842 if(game->get_sbombs())
2258 {
2259 438789 int32_t itemid = current_item_id(itype_sbomb,false);
2260
3/4
✓ Branch 0 taken 437361 times.
✓ Branch 1 taken 1428 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 437361 times.
438789 if(itemid > -1 && checkbunny(itemid))
2261 437361 tile+=itemsbuf[itemid].ltm;
2262 438789 }
2263
2264
2/2
✓ Branch 0 taken 2965573 times.
✓ Branch 1 taken 77269 times.
3042842 if(current_item(itype_clock))
2265 {
2266 77269 int32_t itemid =
2267
1/2
✓ Branch 0 taken 77269 times.
✗ Branch 1 not taken.
77269 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2268 ? iClock
2269 : getHighestLevelEvenUnowned(itemsbuf, itype_clock);
2270
2/4
✓ Branch 0 taken 77269 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 77269 times.
77269 if(itemid > -1 && checkbunny(itemid))
2271 77269 tile+=itemsbuf[itemid].ltm;
2272 77269 }
2273
2274
2/2
✓ Branch 0 taken 2430570 times.
✓ Branch 1 taken 612272 times.
3042842 if(current_item(itype_key))
2275 {
2276 612272 int32_t itemid =
2277
1/2
✓ Branch 0 taken 612272 times.
✗ Branch 1 not taken.
612272 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2278 ? iKey
2279 : getHighestLevelEvenUnowned(itemsbuf, itype_key);
2280
2/4
✓ Branch 0 taken 612272 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 612272 times.
612272 if(itemid > -1 && checkbunny(itemid))
2281 612272 tile+=itemsbuf[itemid].ltm;
2282 612272 }
2283
2284
2/2
✓ Branch 0 taken 2883589 times.
✓ Branch 1 taken 159253 times.
3042842 if(current_item(itype_lkey))
2285 {
2286 159253 int32_t itemid =
2287
2/2
✓ Branch 0 taken 158343 times.
✓ Branch 1 taken 910 times.
159253 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2288 ? iLevelKey
2289 910 : getHighestLevelEvenUnowned(itemsbuf, itype_lkey);
2290
2/4
✓ Branch 0 taken 159253 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 159253 times.
159253 if(itemid > -1 && checkbunny(itemid))
2291 159253 tile+=itemsbuf[itemid].ltm;
2292 159253 }
2293
2294
2/2
✓ Branch 0 taken 836888 times.
✓ Branch 1 taken 2205954 times.
3042842 if(current_item(itype_map))
2295 {
2296 2205954 int32_t itemid =
2297
2/2
✓ Branch 0 taken 2205168 times.
✓ Branch 1 taken 786 times.
2205954 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2298 ? iMap
2299 786 : getHighestLevelEvenUnowned(itemsbuf, itype_map);
2300
2/4
✓ Branch 0 taken 2205954 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2205954 times.
2205954 if(itemid > -1 && checkbunny(itemid))
2301 2205954 tile+=itemsbuf[itemid].ltm;
2302 2205954 }
2303
2304
2/2
✓ Branch 0 taken 754185 times.
✓ Branch 1 taken 2288657 times.
3042842 if(current_item(itype_compass))
2305 {
2306 2288657 int32_t itemid =
2307
2/2
✓ Branch 0 taken 2207598 times.
✓ Branch 1 taken 81059 times.
2288657 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2308 ? iCompass
2309 81059 : getHighestLevelEvenUnowned(itemsbuf, itype_compass);
2310
2/4
✓ Branch 0 taken 2288657 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2288657 times.
2288657 if(itemid > -1 && checkbunny(itemid))
2311 2288657 tile+=itemsbuf[itemid].ltm;
2312 2288657 }
2313
2314
2/2
✓ Branch 0 taken 1232480 times.
✓ Branch 1 taken 1810362 times.
3042842 if(current_item(itype_bosskey))
2315 {
2316 1810362 int32_t itemid =
2317
1/2
✓ Branch 0 taken 1810362 times.
✗ Branch 1 not taken.
1810362 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2318 ? iBossKey
2319 : getHighestLevelEvenUnowned(itemsbuf, itype_bosskey);
2320
2/4
✓ Branch 0 taken 1810362 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1810362 times.
1810362 if(itemid > -1 && checkbunny(itemid))
2321 1810362 tile+=itemsbuf[itemid].ltm;
2322 1810362 }
2323
2324
2/2
✓ Branch 0 taken 2084333 times.
✓ Branch 1 taken 958509 times.
3042842 if(current_item(itype_magiccontainer))
2325 {
2326 958509 int32_t itemid =
2327
2/2
✓ Branch 0 taken 865294 times.
✓ Branch 1 taken 93215 times.
958509 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2328 ? iMagicC
2329 93215 : getHighestLevelEvenUnowned(itemsbuf, itype_magiccontainer);
2330
3/4
✓ Branch 0 taken 958509 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1870 times.
✓ Branch 3 taken 956639 times.
958509 if(itemid > -1 && checkbunny(itemid))
2331 956639 tile+=itemsbuf[itemid].ltm;
2332 958509 }
2333
2334
2/2
✓ Branch 0 taken 1066255 times.
✓ Branch 1 taken 1976587 times.
3042842 if(current_item(itype_triforcepiece))
2335 {
2336 1976587 int32_t itemid =
2337
1/2
✓ Branch 0 taken 1976587 times.
✗ Branch 1 not taken.
1976587 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2338 ? iTriforce
2339 : getHighestLevelEvenUnowned(itemsbuf, itype_triforcepiece);
2340
2/4
✓ Branch 0 taken 1976587 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1976587 times.
1976587 if(itemid > -1 && checkbunny(itemid))
2341 1976587 tile+=itemsbuf[itemid].ltm;
2342 1976587 }
2343
2344
2/2
✓ Branch 0 taken 3042842 times.
✓ Branch 1 taken 1557935104 times.
1560977946 for(int32_t i=0; i<itype_max; i++)
2345 {
2346
2/2
✓ Branch 0 taken 1501633024 times.
✓ Branch 1 taken 56302080 times.
1557935104 if(!get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS))
2347 {
2348
2/2
✓ Branch 0 taken 1099650 times.
✓ Branch 1 taken 55202430 times.
56302080 switch(i)
2349 {
2350 case itype_bomb:
2351 case itype_sbomb:
2352 case itype_clock:
2353 case itype_key:
2354 case itype_lkey:
2355 case itype_map:
2356 case itype_compass:
2357 case itype_bosskey:
2358 case itype_magiccontainer:
2359 case itype_triforcepiece:
2360 1099650 continue; //already handled
2361 }
2362 55202430 }
2363 1556835454 int32_t itemid = current_item_id(i,false);
2364
2/2
✓ Branch 0 taken 1553792612 times.
✓ Branch 1 taken 3042842 times.
1556835454 if(i == itype_shield)
2365 3042842 itemid = getCurrentShield(false);
2366
2367
4/4
✓ Branch 0 taken 42239563 times.
✓ Branch 1 taken 1514595891 times.
✓ Branch 2 taken 100981 times.
✓ Branch 3 taken 42138582 times.
1556835454 if(itemid < 0 || !checkbunny(itemid))
2368 1514696872 continue;
2369
2370 42138582 itemdata const& itm = itemsbuf[itemid];
2371
2372
2/2
✓ Branch 0 taken 39673262 times.
✓ Branch 1 taken 2465320 times.
42138582 switch(itm.family)
2373 {
2374 case itype_shield:
2375
1/2
✓ Branch 0 taken 2465320 times.
✗ Branch 1 not taken.
2465320 if(itm.flags & ITEM_FLAG9) //active shield
2376 {
2377 if(!usingActiveShield(itemid))
2378 {
2379 tile+=itm.misc6; //'Inactive PTM'
2380 continue;
2381 }
2382 }
2383 2465320 break;
2384 }
2385
2386 42138582 tile+=itm.ltm;
2387 42138582 }
2388
2389 3042842 return tile;
2390 }
2391
2392 3042842 int32_t bunny_tile_mod()
2393 {
2394
2/2
✓ Branch 0 taken 1870 times.
✓ Branch 1 taken 3040972 times.
3042842 if(Hero.BunnyClock())
2395 {
2396 1870 return game->get_bunny_ltm();
2397 }
2398 3040972 return 0;
2399 3042842 }
2400
2401 // Hints are drawn on a separate layer to combo reveals.
2402 12952 void draw_lens_under(BITMAP *dest, bool layer)
2403 {
2404 //Lens flag 1: Replacement for qr_LENSHINTS; if set, lens will show hints. Does nothing if flag 2 is set.
2405 //Lens flag 2: Disable "hints", prevent rendering of Secret Combos
2406 //Lens flag 3: Don't show armos/chest/dive items
2407 //Lens flag 4: Show Raft Paths
2408 //Lens flag 5: Show Invisible Enemies
2409
4/4
✓ Branch 0 taken 456 times.
✓ Branch 1 taken 12496 times.
✓ Branch 2 taken 6248 times.
✓ Branch 3 taken 6248 times.
12952 bool hints = (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2) ? false : (layer && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG1));
2410
2411 12952 int32_t strike_hint_table[11]=
2412 {
2413 mfARROW, mfBOMB, mfBRANG, mfWANDMAGIC,
2414 mfSWORD, mfREFMAGIC, mfHOOKSHOT,
2415 mfREFFIREBALL, mfHAMMER, mfSWORDBEAM, mfWAND
2416 };
2417
2418 // int32_t page = tmpscr->cpage;
2419 {
2420
2/2
✓ Branch 0 taken 456 times.
✓ Branch 1 taken 12496 times.
12952 int32_t blink_rate=((get_bit(quest_rules,qr_EPILEPSY) || epilepsyFlashReduction)?6:1);
2421 // int32_t temptimer=0;
2422 12952 int32_t tempitem, tempweapon=0;
2423 12952 strike_hint=strike_hint_table[strike_hint_counter];
2424
2425
2/2
✓ Branch 0 taken 12562 times.
✓ Branch 1 taken 390 times.
12952 if(strike_hint_timer>32)
2426 {
2427 390 strike_hint_timer=0;
2428 390 strike_hint_counter=((strike_hint_counter+1)%11);
2429 390 }
2430
2431 12952 ++strike_hint_timer;
2432
2433
2/2
✓ Branch 0 taken 2279552 times.
✓ Branch 1 taken 12952 times.
2292504 for(int32_t i=0; i<176; i++)
2434 {
2435 2279552 int32_t x = (i & 15) << 4;
2436 2279552 int32_t y = (i & 0xF0) + playing_field_offset;
2437 2279552 int32_t tempitemx=-16, tempitemy=-16;
2438 2279552 int32_t tempweaponx=-16, tempweapony=-16;
2439
2440
2/2
✓ Branch 0 taken 4559104 times.
✓ Branch 1 taken 2279552 times.
6838656 for(int32_t iter=0; iter<2; ++iter)
2441 {
2442 4559104 int32_t checkflag=0;
2443
2444
2/2
✓ Branch 0 taken 2279552 times.
✓ Branch 1 taken 2279552 times.
4559104 if(iter==0)
2445 {
2446 2279552 checkflag=combobuf[tmpscr->data[i]].flag;
2447 2279552 }
2448 else
2449 {
2450 2279552 checkflag=tmpscr->sflag[i];
2451 }
2452
2453
2/2
✓ Branch 0 taken 4558006 times.
✓ Branch 1 taken 1098 times.
4559104 if(checkflag==mfSTRIKE)
2454 {
2455
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 906 times.
1098 if(!hints)
2456 {
2457
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTRIKE],tmpscr->secretcset[sSTRIKE]);
2458 906 }
2459 else
2460 {
2461 192 checkflag = strike_hint;
2462 }
2463 1098 }
2464
2465
19/36
✓ Branch 0 taken 4520712 times.
✓ Branch 1 taken 2638 times.
✓ Branch 2 taken 2808 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2064 times.
✓ Branch 5 taken 28392 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 504 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 814 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 17 times.
✓ Branch 15 taken 96 times.
✓ Branch 16 taken 24 times.
✓ Branch 17 taken 5 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 16 times.
✓ Branch 22 taken 16 times.
✓ Branch 23 taken 7 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 16 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 17 times.
✓ Branch 32 taken 35 times.
✓ Branch 33 taken 17 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 906 times.
4559104 switch(checkflag)
2466 {
2467 case 0:
2468 case mfZELDA:
2469 case mfPUSHED:
2470 case mfENEMY0:
2471 case mfENEMY1:
2472 case mfENEMY2:
2473 case mfENEMY3:
2474 case mfENEMY4:
2475 case mfENEMY5:
2476 case mfENEMY6:
2477 case mfENEMY7:
2478 case mfENEMY8:
2479 case mfENEMY9:
2480 case mfSINGLE:
2481 case mfSINGLE16:
2482 case mfNOENEMY:
2483 case mfTRAP_H:
2484 case mfTRAP_V:
2485 case mfTRAP_4:
2486 case mfTRAP_LR:
2487 case mfTRAP_UD:
2488 case mfNOGROUNDENEMY:
2489 case mfNOBLOCKS:
2490 case mfSCRIPT1:
2491 case mfSCRIPT2:
2492 case mfSCRIPT3:
2493 case mfSCRIPT4:
2494 case mfSCRIPT5:
2495 case mfSCRIPT6:
2496 case mfSCRIPT7:
2497 case mfSCRIPT8:
2498 case mfSCRIPT9:
2499 case mfSCRIPT10:
2500 case mfSCRIPT11:
2501 case mfSCRIPT12:
2502 case mfSCRIPT13:
2503 case mfSCRIPT14:
2504 case mfSCRIPT15:
2505 case mfSCRIPT16:
2506 case mfSCRIPT17:
2507 case mfSCRIPT18:
2508 case mfSCRIPT19:
2509 case mfSCRIPT20:
2510 case mfPITHOLE:
2511 case mfPITFALLFLOOR:
2512 case mfLAVA:
2513 case mfICE:
2514 case mfICEDAMAGE:
2515 case mfDAMAGE1:
2516 case mfDAMAGE2:
2517 case mfDAMAGE4:
2518 case mfDAMAGE8:
2519 case mfDAMAGE16:
2520 case mfDAMAGE32:
2521 case mfFREEZEALL:
2522 case mfFREZEALLANSFFCS:
2523 case mfFREEZEFFCSOLY:
2524 case mfSCRITPTW1TRIG:
2525 case mfSCRITPTW2TRIG:
2526 case mfSCRITPTW3TRIG:
2527 case mfSCRITPTW4TRIG:
2528 case mfSCRITPTW5TRIG:
2529 case mfSCRITPTW6TRIG:
2530 case mfSCRITPTW7TRIG:
2531 case mfSCRITPTW8TRIG:
2532 case mfSCRITPTW9TRIG:
2533 case mfSCRITPTW10TRIG:
2534 case mfTROWEL:
2535 case mfTROWELNEXT:
2536 case mfTROWELSPECIALITEM:
2537 case mfSLASHPOT:
2538 case mfLIFTPOT:
2539 case mfLIFTORSLASH:
2540 case mfLIFTROCK:
2541 case mfLIFTROCKHEAVY:
2542 case mfDROPITEM:
2543 case mfSPECIALITEM:
2544 case mfDROPKEY:
2545 case mfDROPLKEY:
2546 case mfDROPCOMPASS:
2547 case mfDROPMAP:
2548 case mfDROPBOSSKEY:
2549 case mfSPAWNNPC:
2550 case mfSWITCHHOOK:
2551 case mfSIDEVIEWLADDER:
2552 case mfSIDEVIEWPLATFORM:
2553 case mfNOENEMYSPAWN:
2554 case mfENEMYALL:
2555 case mfNOMIRROR:
2556 case mfUNSAFEGROUND:
2557 case mf168:
2558 case mf169:
2559 case mf170:
2560 case mf171:
2561 case mf172:
2562 case mf173:
2563 case mf174:
2564 case mf175:
2565 case mf176:
2566 case mf177:
2567 case mf178:
2568 case mf179:
2569 case mf180:
2570 case mf181:
2571 case mf182:
2572 case mf183:
2573 case mf184:
2574 case mf185:
2575 case mf186:
2576 case mf187:
2577 case mf188:
2578 case mf189:
2579 case mf190:
2580 case mf191:
2581 case mf192:
2582 case mf193:
2583 case mf194:
2584 case mf195:
2585 case mf196:
2586 case mf197:
2587 case mf198:
2588 case mf199:
2589 case mf200:
2590 case mf201:
2591 case mf202:
2592 case mf203:
2593 case mf204:
2594 case mf205:
2595 case mf206:
2596 case mf207:
2597 case mf208:
2598 case mf209:
2599 case mf210:
2600 case mf211:
2601 case mf212:
2602 case mf213:
2603 case mf214:
2604 case mf215:
2605 case mf216:
2606 case mf217:
2607 case mf218:
2608 case mf219:
2609 case mf220:
2610 case mf221:
2611 case mf222:
2612 case mf223:
2613 case mf224:
2614 case mf225:
2615 case mf226:
2616 case mf227:
2617 case mf228:
2618 case mf229:
2619 case mf230:
2620 case mf231:
2621 case mf232:
2622 case mf233:
2623 case mf234:
2624 case mf235:
2625 case mf236:
2626 case mf237:
2627 case mf238:
2628 case mf239:
2629 case mf240:
2630 case mf241:
2631 case mf242:
2632 case mf243:
2633 case mf244:
2634 case mf245:
2635 case mf246:
2636 case mf247:
2637 case mf248:
2638 case mf249:
2639 case mf250:
2640 case mf251:
2641 case mf252:
2642 case mf253:
2643 case mf254:
2644 case mfEXTENDED:
2645 4520712 break;
2646
2647 case mfPUSHUD:
2648 case mfPUSHLR:
2649 case mfPUSH4:
2650 case mfPUSHU:
2651 case mfPUSHD:
2652 case mfPUSHL:
2653 case mfPUSHR:
2654 case mfPUSHUDNS:
2655 case mfPUSHLRNS:
2656 case mfPUSH4NS:
2657 case mfPUSHUNS:
2658 case mfPUSHDNS:
2659 case mfPUSHLNS:
2660 case mfPUSHRNS:
2661 case mfPUSHUDINS:
2662 case mfPUSHLRINS:
2663 case mfPUSH4INS:
2664 case mfPUSHUINS:
2665 case mfPUSHDINS:
2666 case mfPUSHLINS:
2667 case mfPUSHRINS:
2668
3/4
✓ Branch 0 taken 1319 times.
✓ Branch 1 taken 1319 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1319 times.
2638 if(!hints && ((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&16))
2669
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1319 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1319 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1319 || ((get_debug() && zc_getkey(KEY_N)) && (frame&16))))
2670 {
2671 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->undercombo,tmpscr->undercset);
2672 }
2673
2674
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2638 times.
2638 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2675
3/6
✓ Branch 0 taken 1150 times.
✓ Branch 1 taken 1488 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1488 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2638 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2676 {
2677
2/2
✓ Branch 0 taken 575 times.
✓ Branch 1 taken 575 times.
1150 if(hints)
2678 {
2679
3/3
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 42 times.
✓ Branch 2 taken 485 times.
575 switch(combobuf[tmpscr->data[i]].type)
2680 {
2681 case cPUSH_HEAVY:
2682 case cPUSH_HW:
2683 48 tempitem=getItemIDPower(itemsbuf,itype_bracelet,1);
2684 48 tempitemx=x, tempitemy=y;
2685
2686
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(tempitem>-1)
2687 48 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2688
2689 48 break;
2690
2691 case cPUSH_HEAVY2:
2692 case cPUSH_HW2:
2693 42 tempitem=getItemIDPower(itemsbuf,itype_bracelet,2);
2694 42 tempitemx=x, tempitemy=y;
2695
2696
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(tempitem>-1)
2697 42 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2698
2699 42 break;
2700 }
2701 575 }
2702 1150 }
2703
2704 2638 break;
2705
2706 case mfWHISTLE:
2707 if(hints)
2708 {
2709 tempitem=getItemID(itemsbuf,itype_whistle,1);
2710
2711 if(tempitem<0) break;
2712
2713 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2714 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2715 {
2716 tempitemx=x;
2717 tempitemy=y;
2718 }
2719
2720 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2721 }
2722
2723 break;
2724
2725 //Why is this here?
2726 case mfFAIRY:
2727 case mfMAGICFAIRY:
2728 case mfALLFAIRY:
2729 if(hints)
2730 {
2731 tempitem=getItemID(itemsbuf, itype_fairy,1);//iFairyMoving;
2732
2733 if(tempitem < 0) break;
2734
2735 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2736 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2737 {
2738 tempitemx=x;
2739 tempitemy=y;
2740 }
2741
2742 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2743 }
2744
2745 break;
2746
2747 case mfBCANDLE:
2748
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 252 times.
504 if(!hints)
2749 {
2750
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBCANDLE],tmpscr->secretcset[sBCANDLE]);
2751 252 }
2752 else
2753 {
2754 252 tempitem=getItemID(itemsbuf,itype_candle,1);
2755
2756
1/2
✓ Branch 0 taken 252 times.
✗ Branch 1 not taken.
252 if(tempitem<0) break;
2757
2758
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2759
3/6
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 126 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 126 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
252 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2760 {
2761 126 tempitemx=x;
2762 126 tempitemy=y;
2763 126 }
2764
2765 252 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2766 }
2767
2768 504 break;
2769
2770 case mfRCANDLE:
2771 if(!hints)
2772 {
2773 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sRCANDLE],tmpscr->secretcset[sRCANDLE]);
2774 }
2775 else
2776 {
2777 tempitem=getItemID(itemsbuf,itype_candle,2);
2778
2779 if(tempitem<0) break;
2780
2781 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2782 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2783 {
2784 tempitemx=x;
2785 tempitemy=y;
2786 }
2787
2788 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2789 }
2790
2791 break;
2792
2793 case mfWANDFIRE:
2794 if(!hints)
2795 {
2796 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDFIRE],tmpscr->secretcset[sWANDFIRE]);
2797 }
2798 else
2799 {
2800 tempitem=getItemID(itemsbuf,itype_wand,1);
2801
2802 if(tempitem<0) break;
2803
2804 tempweapon=wFire;
2805
2806 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2807 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2808 {
2809 tempitemx=x;
2810 tempitemy=y;
2811 }
2812 else
2813 {
2814 tempweaponx=x;
2815 tempweapony=y;
2816 }
2817
2818 putweapon(dest,tempweaponx,tempweapony,tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2819 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2820 }
2821
2822 break;
2823
2824 case mfDINSFIRE:
2825 if(!hints)
2826 {
2827 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sDINSFIRE],tmpscr->secretcset[sDINSFIRE]);
2828 }
2829 else
2830 {
2831 tempitem=getItemID(itemsbuf,itype_dinsfire,1);
2832
2833 if(tempitem<0) break;
2834
2835 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2836 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2837 {
2838 tempitemx=x;
2839 tempitemy=y;
2840 }
2841
2842 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2843 }
2844
2845 break;
2846
2847 case mfARROW:
2848
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 732 times.
814 if(!hints)
2849 {
2850
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 732 times.
732 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sARROW],tmpscr->secretcset[sARROW]);
2851 732 }
2852 else
2853 {
2854 82 tempitem=getItemID(itemsbuf,itype_arrow,1);
2855
2856
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(tempitem<0) break;
2857
2858
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2859
3/6
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 40 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 40 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
82 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2860 {
2861 42 tempitemx=x;
2862 42 tempitemy=y;
2863 42 }
2864
2865 82 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2866 }
2867
2868 814 break;
2869
2870 case mfSARROW:
2871 if(!hints)
2872 {
2873 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSARROW],tmpscr->secretcset[sSARROW]);
2874 }
2875 else
2876 {
2877 tempitem=getItemID(itemsbuf,itype_arrow,2);
2878
2879 if(tempitem<0) break;
2880
2881 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2882 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2883 {
2884 tempitemx=x;
2885 tempitemy=y;
2886 }
2887
2888 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2889 }
2890
2891 break;
2892
2893 case mfGARROW:
2894 if(!hints)
2895 {
2896 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sGARROW],tmpscr->secretcset[sGARROW]);
2897 }
2898 else
2899 {
2900 tempitem=getItemID(itemsbuf,itype_arrow,3);
2901
2902 if(tempitem<0) break;
2903
2904 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2905 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2906 {
2907 tempitemx=x;
2908 tempitemy=y;
2909 }
2910
2911 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2912 }
2913
2914 break;
2915
2916 case mfBOMB:
2917
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
2918 {
2919 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBOMB],tmpscr->secretcset[sBOMB]);
2920 }
2921 else
2922 {
2923 //tempitem=getItemID(itemsbuf,itype_bomb,1);
2924 17 tempweapon = wLitBomb;
2925
2926 //if (tempitem<0) break;
2927
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2928
3/6
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2929 {
2930 8 tempweaponx=x;
2931 8 tempweapony=y;
2932 8 }
2933
2934 17 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2935 }
2936
2937 17 break;
2938
2939 case mfSBOMB:
2940
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 48 times.
96 if(!hints)
2941 {
2942
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSBOMB],tmpscr->secretcset[sSBOMB]);
2943 48 }
2944 else
2945 {
2946 //tempitem=getItemID(itemsbuf,itype_sbomb,1);
2947 //if (tempitem<0) break;
2948 48 tempweapon = wLitSBomb;
2949
2950
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2951
3/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2952 {
2953 24 tempweaponx=x;
2954 24 tempweapony=y;
2955 24 }
2956
2957 48 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2958 }
2959
2960 96 break;
2961
2962 case mfARMOS_SECRET:
2963
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
24 if(!hints)
2964 {
2965
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
2966 12 }
2967 24 break;
2968
2969 case mfBRANG:
2970
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!hints)
2971 {
2972 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBRANG],tmpscr->secretcset[sBRANG]);
2973 }
2974 else
2975 {
2976 5 tempitem=getItemID(itemsbuf,itype_brang,1);
2977
2978
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(tempitem<0) break;
2979
2980
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2981
3/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2982 {
2983 3 tempitemx=x;
2984 3 tempitemy=y;
2985 3 }
2986
2987 5 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2988 }
2989
2990 5 break;
2991
2992 case mfMBRANG:
2993 if(!hints)
2994 {
2995 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMBRANG],tmpscr->secretcset[sMBRANG]);
2996 }
2997 else
2998 {
2999 tempitem=getItemID(itemsbuf,itype_brang,2);
3000
3001 if(tempitem<0) break;
3002
3003 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3004 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3005 {
3006 tempitemx=x;
3007 tempitemy=y;
3008 }
3009
3010 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3011 }
3012
3013 break;
3014
3015 case mfFBRANG:
3016 if(!hints)
3017 {
3018 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sFBRANG],tmpscr->secretcset[sFBRANG]);
3019 }
3020 else
3021 {
3022 tempitem=getItemID(itemsbuf,itype_brang,3);
3023
3024 if(tempitem<0) break;
3025
3026 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3027 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3028 {
3029 tempitemx=x;
3030 tempitemy=y;
3031 }
3032
3033 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3034 }
3035
3036 break;
3037
3038 case mfWANDMAGIC:
3039 if(!hints)
3040 {
3041 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDMAGIC],tmpscr->secretcset[sWANDMAGIC]);
3042 }
3043 else
3044 {
3045 tempitem=getItemID(itemsbuf,itype_wand,1);
3046
3047 if(tempitem<0) break;
3048
3049 tempweapon=itemsbuf[tempitem].wpn3;
3050
3051 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3052 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3053 {
3054 tempitemx=x;
3055 tempitemy=y;
3056 }
3057 else
3058 {
3059 tempweaponx=x;
3060 tempweapony=y;
3061 --lens_hint_weapon[wMagic][4];
3062
3063 if(lens_hint_weapon[wMagic][4]<-8)
3064 {
3065 lens_hint_weapon[wMagic][4]=8;
3066 }
3067 }
3068
3069 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3070 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3071 }
3072
3073 break;
3074
3075 case mfREFMAGIC:
3076
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3077 {
3078 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFMAGIC],tmpscr->secretcset[sREFMAGIC]);
3079 }
3080 else
3081 {
3082 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3083
3084
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3085
3086 16 tempweapon=ewMagic;
3087
3088
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3089
3/6
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3090 {
3091 8 tempitemx=x;
3092 8 tempitemy=y;
3093 8 }
3094 else
3095 {
3096 8 tempweaponx=x;
3097 8 tempweapony=y;
3098
3099
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1 times.
8 if(lens_hint_weapon[ewMagic][2]==up)
3100 {
3101 1 --lens_hint_weapon[ewMagic][4];
3102 1 }
3103 else
3104 {
3105 7 ++lens_hint_weapon[ewMagic][4];
3106 }
3107
3108
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(lens_hint_weapon[ewMagic][4]>8)
3109 {
3110 lens_hint_weapon[ewMagic][2]=up;
3111 }
3112
3113
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 2 times.
8 if(lens_hint_weapon[ewMagic][4]<=0)
3114 {
3115 2 lens_hint_weapon[ewMagic][2]=down;
3116 2 }
3117 }
3118
3119 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3120 16 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, lens_hint_weapon[ewMagic][2], lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3121 }
3122
3123 16 break;
3124
3125 case mfREFFIREBALL:
3126
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3127 {
3128 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFFIREBALL],tmpscr->secretcset[sREFFIREBALL]);
3129 }
3130 else
3131 {
3132 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3133
3134
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3135
3136 16 tempweapon=ewFireball;
3137
3138
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3139
3/6
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3140 {
3141 8 tempitemx=x;
3142 8 tempitemy=y;
3143 8 tempweaponx=x;
3144 8 tempweapony=y;
3145 8 ++lens_hint_weapon[ewFireball][3];
3146
3147
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(lens_hint_weapon[ewFireball][3]>8)
3148 {
3149 lens_hint_weapon[ewFireball][3]=-8;
3150 lens_hint_weapon[ewFireball][4]=8;
3151 }
3152
3153
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(lens_hint_weapon[ewFireball][3]>0)
3154 {
3155 8 ++lens_hint_weapon[ewFireball][4];
3156 8 }
3157 else
3158 {
3159 --lens_hint_weapon[ewFireball][4];
3160 }
3161 8 }
3162
3163 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3164 16 putweapon(dest,tempweaponx+lens_hint_weapon[tempweapon][3],tempweapony+lens_hint_weapon[ewFireball][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3165 }
3166
3167 16 break;
3168
3169 case mfSWORD:
3170
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!hints)
3171 {
3172 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORD],tmpscr->secretcset[sSWORD]);
3173 }
3174 else
3175 {
3176 7 tempitem=getItemID(itemsbuf,itype_sword,1);
3177
3178
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(tempitem<0) break;
3179
3180
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3181
3/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3182 {
3183 3 tempitemx=x;
3184 3 tempitemy=y;
3185 3 }
3186
3187 7 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3188 }
3189
3190 7 break;
3191
3192 case mfWSWORD:
3193 if(!hints)
3194 {
3195 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORD],tmpscr->secretcset[sWSWORD]);
3196 }
3197 else
3198 {
3199 tempitem=getItemID(itemsbuf,itype_sword,2);
3200
3201 if(tempitem<0) break;
3202
3203 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3204 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3205 {
3206 tempitemx=x;
3207 tempitemy=y;
3208 }
3209
3210 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3211 }
3212
3213 break;
3214
3215 case mfMSWORD:
3216 if(!hints)
3217 {
3218 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORD],tmpscr->secretcset[sMSWORD]);
3219 }
3220 else
3221 {
3222 tempitem=getItemID(itemsbuf,itype_sword,3);
3223
3224 if(tempitem<0) break;
3225
3226 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3227 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3228 {
3229 tempitemx=x;
3230 tempitemy=y;
3231 }
3232
3233 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3234 }
3235
3236 break;
3237
3238 case mfXSWORD:
3239 if(!hints)
3240 {
3241 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORD],tmpscr->secretcset[sXSWORD]);
3242 }
3243 else
3244 {
3245 tempitem=getItemID(itemsbuf,itype_sword,4);
3246
3247 if(tempitem<0) break;
3248
3249 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3250 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3251 {
3252 tempitemx=x;
3253 tempitemy=y;
3254 }
3255
3256 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3257 }
3258
3259 break;
3260
3261 case mfSWORDBEAM:
3262
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3263 {
3264 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORDBEAM],tmpscr->secretcset[sSWORDBEAM]);
3265 }
3266 else
3267 {
3268 16 tempitem=getItemID(itemsbuf,itype_sword,1);
3269
3270
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3271
3272
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3273
3/6
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3274 {
3275 8 tempitemx=x;
3276 8 tempitemy=y;
3277 8 }
3278
3279 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 1);
3280 }
3281
3282 16 break;
3283
3284 case mfWSWORDBEAM:
3285 if(!hints)
3286 {
3287 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORDBEAM],tmpscr->secretcset[sWSWORDBEAM]);
3288 }
3289 else
3290 {
3291 tempitem=getItemID(itemsbuf,itype_sword,2);
3292
3293 if(tempitem<0) break;
3294
3295 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3296 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3297 {
3298 tempitemx=x;
3299 tempitemy=y;
3300 }
3301
3302 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 2);
3303 }
3304
3305 break;
3306
3307 case mfMSWORDBEAM:
3308 if(!hints)
3309 {
3310 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORDBEAM],tmpscr->secretcset[sMSWORDBEAM]);
3311 }
3312 else
3313 {
3314 tempitem=getItemID(itemsbuf,itype_sword,3);
3315
3316 if(tempitem<0) break;
3317
3318 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3319 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3320 {
3321 tempitemx=x;
3322 tempitemy=y;
3323 }
3324
3325 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 3);
3326 }
3327
3328 break;
3329
3330 case mfXSWORDBEAM:
3331 if(!hints)
3332 {
3333 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORDBEAM],tmpscr->secretcset[sXSWORDBEAM]);
3334 }
3335 else
3336 {
3337 tempitem=getItemID(itemsbuf,itype_sword,4);
3338
3339 if(tempitem<0) break;
3340
3341 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3342 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3343 {
3344 tempitemx=x;
3345 tempitemy=y;
3346 }
3347
3348 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 4);
3349 }
3350
3351 break;
3352
3353 case mfHOOKSHOT:
3354
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3355 {
3356 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHOOKSHOT],tmpscr->secretcset[sHOOKSHOT]);
3357 }
3358 else
3359 {
3360 17 tempitem=getItemID(itemsbuf,itype_hookshot,1);
3361
3362
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3363
3364
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3365
3/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3366 {
3367 9 tempitemx=x;
3368 9 tempitemy=y;
3369 9 }
3370
3371 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3372 }
3373
3374 17 break;
3375
3376 case mfWAND:
3377
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!hints)
3378 {
3379 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWAND],tmpscr->secretcset[sWAND]);
3380 }
3381 else
3382 {
3383 35 tempitem=getItemID(itemsbuf,itype_wand,1);
3384
3385
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(tempitem<0) break;
3386
3387
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3388
3/6
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 18 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
35 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3389 {
3390 17 tempitemx=x;
3391 17 tempitemy=y;
3392 17 }
3393
3394 35 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3395 }
3396
3397 35 break;
3398
3399 case mfHAMMER:
3400
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3401 {
3402 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHAMMER],tmpscr->secretcset[sHAMMER]);
3403 }
3404 else
3405 {
3406 17 tempitem=getItemID(itemsbuf,itype_hammer,1);
3407
3408
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3409
3410
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3411
3/6
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3412 {
3413 8 tempitemx=x;
3414 8 tempitemy=y;
3415 8 }
3416
3417 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3418 }
3419
3420 17 break;
3421
3422 case mfARMOS_ITEM:
3423 case mfDIVE_ITEM:
3424
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2064 times.
2064 if((!getmapflag() || (tmpscr->flags9&fBELOWRETURN)) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG3))
3425 {
3426 2064 putitem2(dest,x,y,tmpscr->catchall, lens_hint_item[tmpscr->catchall][0], lens_hint_item[tmpscr->catchall][1], 0);
3427 2064 }
3428 2064 break;
3429
3430 case 16:
3431 case 17:
3432 case 18:
3433 case 19:
3434 case 20:
3435 case 21:
3436 case 22:
3437 case 23:
3438 case 24:
3439 case 25:
3440 case 26:
3441 case 27:
3442 case 28:
3443 case 29:
3444 case 30:
3445 case 31:
3446
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 1800 times.
2808 if(!hints)
3447
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1800 times.
3600 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3448 1800 putcombo(dest,x,y,tmpscr->secretcombo[checkflag-16+4],tmpscr->secretcset[checkflag-16+4]);
3449
3450 2808 break;
3451 case mfSECRETSNEXT:
3452 if(!hints)
3453 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3454 putcombo(dest,x,y,tmpscr->data[i]+1,tmpscr->cset[i]);
3455
3456 break;
3457
3458 case mfSTRIKE:
3459
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3460 {
3461 906 goto special;
3462 }
3463 else
3464 {
3465 break;
3466 }
3467
3468 28392 default: goto special;
3469
3470 special:
3471
8/8
✓ Branch 0 taken 14553 times.
✓ Branch 1 taken 14745 times.
✓ Branch 2 taken 465 times.
✓ Branch 3 taken 14088 times.
✓ Branch 4 taken 441 times.
✓ Branch 5 taken 24 times.
✓ Branch 6 taken 6108 times.
✓ Branch 7 taken 8004 times.
29298 if(layer && ((checkflag!=mfRAFT && checkflag!=mfRAFT_BRANCH&& checkflag!=mfRAFT_BOUNCE) ||(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG4)))
3472 {
3473
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6549 times.
✓ Branch 2 taken 3274 times.
✓ Branch 3 taken 3275 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3275 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6549 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate)) || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3474 {
3475 3274 rectfill(dest,x,y,x+15,y+15,WHITE);
3476 3274 }
3477 6549 }
3478
3479 29298 break;
3480 }
3481 4559104 }
3482 2279552 }
3483
3484
2/2
✓ Branch 0 taken 6476 times.
✓ Branch 1 taken 6476 times.
12952 if(layer)
3485 {
3486
2/2
✓ Branch 0 taken 6368 times.
✓ Branch 1 taken 108 times.
6476 if(tmpscr->door[0]==dWALK)
3487 108 rectfill(dest, 120, 16+playing_field_offset, 135, 31+playing_field_offset, WHITE);
3488
3489
2/2
✓ Branch 0 taken 6368 times.
✓ Branch 1 taken 108 times.
6476 if(tmpscr->door[1]==dWALK)
3490 108 rectfill(dest, 120, 144+playing_field_offset, 135, 159+playing_field_offset, WHITE);
3491
3492
1/2
✓ Branch 0 taken 6476 times.
✗ Branch 1 not taken.
6476 if(tmpscr->door[2]==dWALK)
3493 rectfill(dest, 16, 80+playing_field_offset, 31, 95+playing_field_offset, WHITE);
3494
3495
1/2
✓ Branch 0 taken 6476 times.
✗ Branch 1 not taken.
6476 if(tmpscr->door[3]==dWALK)
3496 rectfill(dest, 224, 80+playing_field_offset, 239, 95+playing_field_offset, WHITE);
3497
3498
2/2
✓ Branch 0 taken 6452 times.
✓ Branch 1 taken 24 times.
6476 if(tmpscr->door[0]==dBOMB)
3499 {
3500 24 showbombeddoor(dest, 0);
3501 24 }
3502
3503
2/2
✓ Branch 0 taken 6452 times.
✓ Branch 1 taken 24 times.
6476 if(tmpscr->door[1]==dBOMB)
3504 {
3505 24 showbombeddoor(dest, 1);
3506 24 }
3507
3508
1/2
✓ Branch 0 taken 6476 times.
✗ Branch 1 not taken.
6476 if(tmpscr->door[2]==dBOMB)
3509 {
3510 showbombeddoor(dest, 2);
3511 }
3512
3513
1/2
✓ Branch 0 taken 6476 times.
✗ Branch 1 not taken.
6476 if(tmpscr->door[3]==dBOMB)
3514 {
3515 showbombeddoor(dest, 3);
3516 }
3517 6476 }
3518
3519
2/2
✓ Branch 0 taken 11130 times.
✓ Branch 1 taken 1822 times.
12952 if(tmpscr->stairx + tmpscr->stairy)
3520 {
3521
2/2
✓ Branch 0 taken 911 times.
✓ Branch 1 taken 911 times.
1822 if(!hints)
3522 {
3523
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 911 times.
911 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3524 911 putcombo(dest,tmpscr->stairx,tmpscr->stairy+playing_field_offset,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3525 911 }
3526 else
3527 {
3528
2/2
✓ Branch 0 taken 863 times.
✓ Branch 1 taken 48 times.
911 if(tmpscr->flags&fWHISTLE)
3529 {
3530 48 tempitem=getItemID(itemsbuf,itype_whistle,1);
3531 48 int32_t tempitemx=-16;
3532 48 int32_t tempitemy=-16;
3533
3534
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&(blink_rate/4)))
3535
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 48 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&(blink_rate/4))))
3536 {
3537 tempitemx=tmpscr->stairx;
3538 tempitemy=tmpscr->stairy+playing_field_offset;
3539 }
3540
3541 48 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3542 48 }
3543 }
3544 1822 }
3545 }
3546 12952 }
3547
3548 BITMAP *lens_scr_d; // The "d" is for "destructible"!
3549
3550 6307 void draw_lens_over()
3551 {
3552 // Oh, what the heck.
3553 static BITMAP *lens_scr = NULL;
3554 static int32_t last_width = -1;
3555 6307 int32_t width = itemsbuf[current_item_id(itype_lens,true)].misc1;
3556
3557 // Only redraw the circle if the size has changed
3558
2/2
✓ Branch 0 taken 6303 times.
✓ Branch 1 taken 4 times.
6307 if(width != last_width)
3559 {
3560
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(lens_scr == NULL)
3561 {
3562 4 lens_scr = create_bitmap_ex(8,2*288,2*(240-playing_field_offset));
3563 4 }
3564
3565 4 clear_to_color(lens_scr, BLACK);
3566 4 circlefill(lens_scr, 288, 240-playing_field_offset, width, 0);
3567 4 circle(lens_scr, 288, 240-playing_field_offset, width+2, 0);
3568 4 circle(lens_scr, 288, 240-playing_field_offset, width+5, 0);
3569 4 last_width=width;
3570 4 }
3571
3572 6307 masked_blit(lens_scr, framebuf, 288-(HeroX()+8), 240-playing_field_offset-(HeroY()+8), 0, playing_field_offset, 256, 168);
3573 6307 }
3574
3575 //----------------------------------------------------------------
3576
3577 30701 void draw_wavy(BITMAP *source, BITMAP *target, int32_t amplitude, bool interpol)
3578 {
3579 //recreating a big bitmap every frame is highly sluggish.
3580
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 30699 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
30701 static BITMAP *wavebuf = create_bitmap_ex(8,288,240-original_playing_field_offset);
3581 30701 clear_to_color(wavebuf, BLACK);
3582 30701 blit(source,wavebuf,0,original_playing_field_offset,16,0,256,224-original_playing_field_offset);
3583
3584 int32_t ofs;
3585 // int32_t amplitude=8;
3586 // int32_t wavelength=4;
3587
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30701 times.
30701 amplitude = zc_min(2048,amplitude); // some arbitrary limit to prevent crashing
3588
2/6
✓ Branch 0 taken 30701 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30701 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30701 if((epilepsyFlashReduction || get_bit(quest_rules,qr_EPILEPSY)) && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY)) amplitude = zc_min(16,amplitude);
3589 30701 int32_t amp2=168;
3590
2/4
✓ Branch 0 taken 30701 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30701 times.
✗ Branch 3 not taken.
30701 if((epilepsyFlashReduction || get_bit(quest_rules,qr_EPILEPSY)) && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY_2)) amp2*=2;
3591 30701 int32_t i=frame%amp2;
3592
3593
2/2
✓ Branch 0 taken 5157768 times.
✓ Branch 1 taken 30701 times.
5188469 for(int32_t j=0; j<168; j++)
3594 {
3595
3/4
✓ Branch 0 taken 2578884 times.
✓ Branch 1 taken 2578884 times.
✓ Branch 2 taken 2578884 times.
✗ Branch 3 not taken.
5157768 if(j&1 && interpol)
3596 {
3597 // Add 288*2048 to ensure it's never negative. It'll get modded out.
3598 ofs=288*2048+int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3599 }
3600 else
3601 {
3602 5157768 ofs=288*2048-int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3603 }
3604
3605
1/2
✓ Branch 0 taken 5157768 times.
✗ Branch 1 not taken.
5157768 if(ofs)
3606 {
3607
2/2
✓ Branch 0 taken 1320388608 times.
✓ Branch 1 taken 5157768 times.
1325546376 for(int32_t k=0; k<256; k++)
3608 {
3609 1320388608 target->line[j+original_playing_field_offset][k]=wavebuf->line[j][(k+ofs+16)%288];
3610 1320388608 }
3611 5157768 }
3612 5157768 }
3613 30701 }
3614
3615 576 void draw_fuzzy(int32_t fuzz)
3616 // draws from right half of scrollbuf to framebuf
3617 {
3618 int32_t firstx, firsty, xstep, ystep, i, y, dx, dy;
3619 byte *start, *si, *di;
3620
3621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 576 times.
576 if(fuzz<1)
3622 fuzz = 1;
3623
3624 576 xstep = 128%fuzz;
3625
3626
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 456 times.
576 if(xstep > 0)
3627 456 xstep = fuzz-xstep;
3628
3629 576 ystep = 112%fuzz;
3630
3631
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 408 times.
576 if(ystep > 0)
3632 408 ystep = fuzz-ystep;
3633
3634 576 firsty = 1;
3635
3636
2/2
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 20784 times.
21360 for(y=0; y<224;)
3637 {
3638 20784 start = &(scrollbuf->line[y][256]);
3639
3640
4/4
✓ Branch 0 taken 20496 times.
✓ Branch 1 taken 129312 times.
✓ Branch 2 taken 129024 times.
✓ Branch 3 taken 20784 times.
149808 for(dy=0; dy<ystep && dy+y<224; dy++)
3641 {
3642 129024 si = start;
3643 129024 di = &(framebuf->line[y+dy][0]);
3644 129024 i = xstep;
3645 129024 firstx = 1;
3646
3647
2/2
✓ Branch 0 taken 33030144 times.
✓ Branch 1 taken 129024 times.
33159168 for(dx=0; dx<256; dx++)
3648 {
3649 33030144 *(di++) = *si;
3650
3651
2/2
✓ Branch 0 taken 27831552 times.
✓ Branch 1 taken 5198592 times.
33030144 if(++i >= fuzz)
3652 {
3653
2/2
✓ Branch 0 taken 5069568 times.
✓ Branch 1 taken 129024 times.
5198592 if(!firstx)
3654 5069568 si += fuzz;
3655 else
3656 {
3657 129024 si += fuzz-xstep;
3658 129024 firstx = 0;
3659 }
3660
3661 5198592 i = 0;
3662 5198592 }
3663 33030144 }
3664 129024 }
3665
3666
2/2
✓ Branch 0 taken 20208 times.
✓ Branch 1 taken 576 times.
20784 if(!firsty)
3667 20208 y += fuzz;
3668 else
3669 {
3670 576 y += ystep;
3671 576 ystep = fuzz;
3672 576 firsty = 0;
3673 }
3674 }
3675 576 }
3676
3677 4800661 void updatescr(bool allowwavy)
3678 {
3679
4/6
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 4800633 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 28 times.
✓ Branch 4 taken 28 times.
✗ Branch 5 not taken.
4800661 static BITMAP *wavybuf = create_bitmap_ex(8,256,224);
3680
4/6
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 4800633 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 28 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 28 times.
4800661 static BITMAP *panorama = create_bitmap_ex(8,256,224);
3681
3682
2/2
✓ Branch 0 taken 4774957 times.
✓ Branch 1 taken 25704 times.
4800661 if(toogam)
3683 {
3684 25704 textout_ex(framebuf,font,"no walls",8,216,1,-1);
3685 25704 }
3686
3687
1/2
✓ Branch 0 taken 4800661 times.
✗ Branch 1 not taken.
4800661 if(Showpal)
3688 dump_pal(framebuf);
3689
3690
2/2
✓ Branch 0 taken 4732888 times.
✓ Branch 1 taken 67773 times.
4800661 if(!Playing)
3691 67773 black_opening_count=0;
3692
3693
2/2
✓ Branch 0 taken 4777957 times.
✓ Branch 1 taken 22704 times.
4800661 if(black_opening_count<0) //shape is opening up
3694 {
3695 22704 black_opening(framebuf,black_opening_x,black_opening_y,(66+black_opening_count),66);
3696
3697
2/4
✓ Branch 0 taken 22704 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 22704 times.
22704 if(Advance||(!Paused))
3698 {
3699 22704 ++black_opening_count;
3700 22704 }
3701 22704 }
3702
2/2
✓ Branch 0 taken 4768717 times.
✓ Branch 1 taken 9240 times.
4777957 else if(black_opening_count>0) //shape is closing
3703 {
3704 9240 black_opening(framebuf,black_opening_x,black_opening_y,black_opening_count,66);
3705
3706
2/4
✓ Branch 0 taken 9240 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9240 times.
9240 if(Advance||(!Paused))
3707 {
3708 9240 --black_opening_count;
3709 9240 }
3710 9240 }
3711
3712
3/4
✓ Branch 0 taken 4769201 times.
✓ Branch 1 taken 31460 times.
✓ Branch 2 taken 4769201 times.
✗ Branch 3 not taken.
4800661 if(black_opening_count==0&&black_opening_shape==bosFADEBLACK)
3713 {
3714 black_opening_shape = bosCIRCLE;
3715 memcpy(RAMpal, tempblackpal, PAL_SIZE*sizeof(RGB));
3716 refreshTints();
3717 refreshpal=true;
3718 }
3719
3720
2/2
✓ Branch 0 taken 4689122 times.
✓ Branch 1 taken 111539 times.
4800661 if(refreshpal)
3721 {
3722 111539 refreshpal=false;
3723 111539 RAMpal[253] = _RGB(0,0,0);
3724 111539 RAMpal[254] = _RGB(63,63,63);
3725 111539 hw_palette = &RAMpal;
3726 111539 update_hw_pal = true;
3727
3728 111539 create_rgb_table(&rgb_table, RAMpal, NULL);
3729 111539 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3730 111539 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3731
3732
2/2
✓ Branch 0 taken 28553984 times.
✓ Branch 1 taken 111539 times.
28665523 for(int32_t q=0; q<PAL_SIZE; q++)
3733 {
3734 28553984 trans_table2.data[0][q] = q;
3735 28553984 trans_table2.data[q][q] = q;
3736 28553984 }
3737 111539 }
3738
3739 4800661 bool clearwavy = (wavy <= 0);
3740
3741
2/2
✓ Branch 0 taken 7245 times.
✓ Branch 1 taken 4793416 times.
4800661 if(wavy <= 0)
3742 {
3743 // So far one thing can alter wavy apart from scripts: Wavy DMaps.
3744 4793416 wavy = (DMaps[currdmap].flags&dmfWAVY ? 4 : 0);
3745 4793416 }
3746
3747 4800661 blit(framebuf, wavybuf, 0, 0, 0, 0, 256, 224);
3748
3749
6/6
✓ Branch 0 taken 30951 times.
✓ Branch 1 taken 4769710 times.
✓ Branch 2 taken 30829 times.
✓ Branch 3 taken 122 times.
✓ Branch 4 taken 128 times.
✓ Branch 5 taken 30701 times.
4800661 if(wavy && Playing && allowwavy)
3750 {
3751 30701 draw_wavy(framebuf, wavybuf, wavy,false);
3752 30701 }
3753
3754
2/2
✓ Branch 0 taken 4793416 times.
✓ Branch 1 taken 7245 times.
4800661 if(clearwavy)
3755 4793416 wavy = 0; // Wavy was set by a DMap flag. Clear it.
3756
2/4
✓ Branch 0 taken 7245 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7245 times.
7245 else if(Playing && !Paused)
3757 7245 wavy--; // Wavy was set by a script. Decrement it.
3758
3759
5/6
✓ Branch 0 taken 4732888 times.
✓ Branch 1 taken 67773 times.
✓ Branch 2 taken 97913 times.
✓ Branch 3 taken 4634975 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 97913 times.
4800661 if(Playing && msgpos && !screenscrolling)
3760 {
3761
1/2
✓ Branch 0 taken 97913 times.
✗ Branch 1 not taken.
97913 if(!(msg_bg_display_buf->clip))
3762 97913 blit_msgstr_bg(framebuf,0,0,0,playing_field_offset,256,168);
3763
1/2
✓ Branch 0 taken 97913 times.
✗ Branch 1 not taken.
97913 if(!(msg_portrait_display_buf->clip))
3764 97913 blit_msgstr_prt(framebuf,0,0,0,playing_field_offset,256,168);
3765
1/2
✓ Branch 0 taken 97913 times.
✗ Branch 1 not taken.
97913 if(!(msg_txt_display_buf->clip))
3766 97913 blit_msgstr_fg(framebuf,0,0,0,playing_field_offset,256,168);
3767 97913 }
3768
3769 /*
3770 if(!(msg_txt_display_buf->clip) && Playing && msgpos && !screenscrolling)
3771 {
3772 BITMAP* subBmp = 0;
3773 masked_blit(msg_txt_display_buf,subBmp,0,0,0,playing_field_offset,256,168);
3774 // masked_blit(msg_txt_display_buf,subBmp,0,playing_field_offset,256,168);
3775 draw_trans_sprite(framebuf, subBmp, 0, playing_field_offset);
3776 destroy_bitmap(subBmp);
3777 //void draw_sprite_ex(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t mode, int32_t flip);
3778 // masked_blit(msg_txt_display_buf,framebuf,0,0,0,playing_field_offset,256,168);
3779 //void masked_blit(BITMAP *source, BITMAP *dest, int32_t source_x, int32_t source_y, int32_t dest_x, int32_t dest_y, int32_t width, int32_t height);
3780 }
3781 */
3782
3783
2/2
✓ Branch 0 taken 4779400 times.
✓ Branch 1 taken 21261 times.
4800661 bool nosubscr = (tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET));
3784
3785
2/2
✓ Branch 0 taken 4779400 times.
✓ Branch 1 taken 21261 times.
4800661 if(nosubscr)
3786 {
3787 21261 rectfill(panorama,0,0,255,passive_subscreen_height/2,0);
3788 21261 rectfill(panorama,0,168+passive_subscreen_height/2,255,168+passive_subscreen_height-1,0);
3789 21261 blit(wavybuf,panorama,0,playing_field_offset,0,passive_subscreen_height/2,256,224-passive_subscreen_height);
3790 21261 }
3791
3792 //TODO: Optimize blit 'overcalls' -Gleeok
3793
2/2
✓ Branch 0 taken 21261 times.
✓ Branch 1 taken 4779400 times.
4800661 BITMAP *source = nosubscr ? panorama : wavybuf;
3794 4800661 blit(source,framebuf,0,0,0,0,256,224);
3795
3796 4800661 update_hw_screen();
3797 4800661 }
3798
3799 //----------------------------------------------------------------
3800
3801 PALETTE sys_pal;
3802
3803 int32_t onGUISnapshot()
3804 {
3805 char buf[200];
3806 int32_t num=0;
3807 bool realpal=(key[KEY_ZC_LCONTROL] || key[KEY_ZC_RCONTROL]);
3808 do
3809 {
3810 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3811 }
3812 while(num<99999 && exists(buf));
3813
3814 BITMAP *b = create_bitmap_ex(8,resx,resy);
3815
3816 if(b)
3817 {
3818 if(MenuOpen)
3819 {
3820 //Cannot load game's palette while GUI elements are in focus. -Z
3821 //If there is a way to do this, then I have missed it.
3822 /*
3823 game_pal();
3824 RAMpal[253] = _RGB(0,0,0);
3825 RAMpal[254] = _RGB(63,63,63);
3826 set_palette_range(RAMpal,0,255,false);
3827 memcpy(RAMpal, snappal, sizeof(snappal));
3828 create_rgb_table(&rgb_table, RAMpal, NULL);
3829 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3830 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3831
3832 for(int32_t q=0; q<PAL_SIZE; q++)
3833 {
3834 trans_table2.data[0][q] = q;
3835 trans_table2.data[q][q] = q;
3836 }
3837 */
3838 //ringcolor(false);
3839 //get_palette(RAMpal);
3840 blit(screen,b,0,0,0,0,resx,resy);
3841 //al_trace("Menu Open\n");
3842 //game_pal();
3843 //PALETTE temppal;
3844 //get_palette(temppal);
3845 //system_pal();
3846 save_bitmap(buf,b,sys_pal);
3847 //save_bitmap(buf,b,RAMpal);
3848 //save_bitmap(buf,b,snappal);
3849 }
3850 else
3851 {
3852 blit(screen,b,0,0,0,0,resx,resy);
3853 save_bitmap(buf,b,realpal?sys_pal:RAMpal);
3854 }
3855 destroy_bitmap(b);
3856 }
3857
3858 return D_O_K;
3859 }
3860
3861 int32_t onNonGUISnapshot()
3862 {
3863 PALETTE temppal;
3864 get_palette(temppal);
3865 bool realpal=(zc_getkey(KEY_ZC_LCONTROL, true) || zc_getkey(KEY_ZC_RCONTROL, true));
3866
3867 char buf[200];
3868 int32_t num=0;
3869
3870 do
3871 {
3872 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3873 }
3874 while(num<99999 && exists(buf));
3875
3876 save_bitmap(buf,framebuf,realpal?temppal:RAMpal);
3877
3878 return D_O_K;
3879 }
3880
3881 int32_t onSnapshot()
3882 {
3883 if(zc_getkey(KEY_LSHIFT, true)||zc_getkey(KEY_RSHIFT, true))
3884 {
3885 onGUISnapshot();
3886 }
3887 else
3888 {
3889 onNonGUISnapshot();
3890 }
3891
3892 return D_O_K;
3893 }
3894
3895 int32_t onSaveMapPic()
3896 {
3897 int32_t mapres2 = 0;
3898 char buf[200];
3899 int32_t num=0;
3900 mapscr tmpscr_b[2];
3901 mapscr tmpscr_c[6];
3902 BITMAP* _screen_draw_buffer = NULL;
3903 _screen_draw_buffer = create_bitmap_ex(8,256,224);
3904 set_clip_state(_screen_draw_buffer,1);
3905
3906 for(int32_t i=0; i<6; ++i)
3907 {
3908 tmpscr_c[i] = tmpscr2[i];
3909 tmpscr2[i].zero_memory();
3910
3911 if(i>=2)
3912 {
3913 continue;
3914 }
3915
3916 tmpscr_b[i] = tmpscr[i];
3917 tmpscr[i].zero_memory();
3918 }
3919
3920 do
3921 {
3922 sprintf(buf, "%szc_screen%05d.png", get_snap_str(), ++num);
3923 }
3924 while(num<99999 && exists(buf));
3925
3926 BITMAP* mappic = NULL;
3927
3928
3929 bool done=false, redraw=true;
3930
3931 mappic = create_bitmap_ex(8,(256*16)>>mapres,(176*8)>>mapres);
3932
3933 if(!mappic)
3934 {
3935 system_pal();
3936 jwin_alert("View Map","Not enough memory.",NULL,NULL,"OK",NULL,13,27,lfont);
3937 game_pal();
3938 return D_O_K;;
3939 }
3940
3941 // draw the map
3942 set_clip_rect(_screen_draw_buffer, 0, 0, _screen_draw_buffer->w, _screen_draw_buffer->h);
3943
3944 for(int32_t y=0; y<8; y++)
3945 {
3946 for(int32_t x=0; x<16; x++)
3947 {
3948 if(!displayOnMap(x, y))
3949 {
3950 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
3951 }
3952 else
3953 {
3954 int32_t s = (y<<4) + x;
3955 loadscr2(1,s,-1);
3956
3957 for(int32_t i=0; i<6; i++)
3958 {
3959 if(tmpscr[1].layermap[i]<=0)
3960 continue;
3961
3962 if((ZCMaps[tmpscr[1].layermap[i]-1].tileWidth==ZCMaps[currmap].tileWidth) &&
3963 (ZCMaps[tmpscr[1].layermap[i]-1].tileHeight==ZCMaps[currmap].tileHeight))
3964 {
3965 const int32_t _mapsSize = (ZCMaps[currmap].tileWidth)*(ZCMaps[currmap].tileHeight);
3966
3967 tmpscr2[i]=TheMaps[(tmpscr[1].layermap[i]-1)*MAPSCRS+tmpscr[1].layerscreen[i]];
3968 }
3969 }
3970
3971 if(XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
3972
3973 if(XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
3974
3975 putscr(_screen_draw_buffer,256,0,tmpscr+1);
3976 do_layer(_screen_draw_buffer, 0, 1, tmpscr+1, -256, playing_field_offset, 2);
3977
3978 if(!XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
3979
3980 putscrdoors(_screen_draw_buffer,256,0,tmpscr+1);
3981 do_layer(_screen_draw_buffer, -2, 0, tmpscr+1, -256, playing_field_offset, 2);
3982 if(get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2))
3983 {
3984 do_layer(_screen_draw_buffer, -2, 1, tmpscr+1, -256, playing_field_offset, 2);
3985 do_layer(_screen_draw_buffer, -2, 2, tmpscr+1, -256, playing_field_offset, 2);
3986 }
3987 do_layer(_screen_draw_buffer, -3, 0, tmpscr+1, -256, playing_field_offset, 2); // Freeform combos!
3988
3989 if(!XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
3990
3991 do_layer(_screen_draw_buffer, 0, 4, tmpscr+1, -256, playing_field_offset, 2);
3992 do_layer(_screen_draw_buffer, -1, 0, tmpscr+1, -256, playing_field_offset, 2);
3993 if(get_bit(quest_rules, qr_OVERHEAD_COMBOS_L1_L2))
3994 {
3995 do_layer(_screen_draw_buffer, -1, 1, tmpscr+1, -256, playing_field_offset, 2);
3996 do_layer(_screen_draw_buffer, -1, 2, tmpscr+1, -256, playing_field_offset, 2);
3997 }
3998 do_layer(_screen_draw_buffer, 0, 5, tmpscr+1, -256, playing_field_offset, 2);
3999 do_layer(_screen_draw_buffer, 0, 6, tmpscr+1, -256, playing_field_offset, 2);
4000
4001 }
4002
4003 stretch_blit(_screen_draw_buffer, mappic, 256, 0, 256, 176, x<<(8-mapres), (y*176)>>mapres, 256>>mapres, 176>>mapres);
4004 }
4005 }
4006
4007 for(int32_t i=0; i<6; ++i)
4008 {
4009 tmpscr2[i]=tmpscr_c[i];
4010
4011 if(i>=2)
4012 {
4013 continue;
4014 }
4015
4016 tmpscr[i]=tmpscr_b[i];
4017 }
4018
4019 save_bitmap(buf,mappic,RAMpal);
4020 destroy_bitmap(mappic);
4021 destroy_bitmap(_screen_draw_buffer);
4022 return D_O_K;
4023 }
4024
4025 /*
4026 int32_t onSaveMapPic()
4027 {
4028 BITMAP* mappic = NULL;
4029 BITMAP* _screen_draw_buffer = NULL;
4030 _screen_draw_buffer = create_bitmap_ex(8,256,224);
4031 int32_t mapres2 = 0;
4032 char buf[20];
4033 int32_t num=0;
4034 set_clip_state(_screen_draw_buffer,1);
4035 set_clip_rect(_screen_draw_buffer,0,0,_screen_draw_buffer->w, _screen_draw_buffer->h);
4036
4037 do
4038 {
4039 sprintf(buf, "zelda%03d.png", ++num);
4040 }
4041 while(num<999 && exists(buf));
4042
4043 // if(!mappic) {
4044 mappic = create_bitmap_ex(8,(256*16)>>mapres2,(176*8)>>mapres2);
4045
4046 if(!mappic)
4047 {
4048 system_pal();
4049 jwin_alert("Save Map Picture","Not enough memory.",NULL,NULL,"OK",NULL,13,27,lfont);
4050 game_pal();
4051 return D_O_K;
4052 }
4053
4054 // }
4055
4056 int32_t layermap, layerscreen;
4057 int32_t x2=0;
4058
4059 // draw the map
4060 for(int32_t y=0; y<8; y++)
4061 {
4062 for(int32_t x=0; x<16; x++)
4063 {
4064 int32_t s = (y<<4) + x;
4065
4066 if(!displayOnMap(x, y))
4067 {
4068 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4069 }
4070 else
4071 {
4072 loadscr(TEMPSCR_FUNCTION_SWAP_SPACE,currdmap,s,-1,false);
4073 putscr(_screen_draw_buffer, 0, 0, tmpscr+1);
4074
4075 for(int32_t k=0; k<4; k++)
4076 {
4077 if(k==2)
4078 {
4079 putscrdoors(_screen_draw_buffer, 0, 0, tmpscr+1);
4080 }
4081
4082 layermap=TheMaps[currmap*MAPSCRS+s].layermap[k]-1;
4083
4084 if(layermap>-1)
4085 {
4086 layerscreen=layermap*MAPSCRS+TheMaps[currmap*MAPSCRS+s].layerscreen[k];
4087
4088 if(TheMaps[currmap*MAPSCRS+s].layeropacity[k]==255)
4089 {
4090 for(int32_t i=0; i<176; i++)
4091 {
4092 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i]);
4093 }
4094 }
4095 else
4096 {
4097 for(int32_t i=0; i<176; i++)
4098 {
4099 overcombotranslucent(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i],TheMaps[currmap*MAPSCRS+s].layeropacity[k]);
4100 }
4101 }
4102 }
4103 }
4104
4105 for(int32_t i=0; i<176; i++)
4106 {
4107 // if (COMBOTYPE((i&15)<<4,i&0xF0)==cOLD_OVERHEAD)
4108 if(combo_class_buf[COMBOTYPE((i&15)<<4,i&0xF0)].overhead)
4109 {
4110 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),MAPCOMBO((i&15)<<4,i&0xF0),MAPCSET((i&15)<<4,i&0xF0));
4111 }
4112 }
4113
4114 for(int32_t k=4; k<6; k++)
4115 {
4116 layermap=TheMaps[currmap*MAPSCRS+s].layermap[k]-1;
4117
4118 if(layermap>-1)
4119 {
4120 layerscreen=layermap*MAPSCRS+TheMaps[currmap*MAPSCRS+s].layerscreen[k];
4121
4122 if(TheMaps[currmap*MAPSCRS+s].layeropacity[k]==255)
4123 {
4124 for(int32_t i=0; i<176; i++)
4125 {
4126 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i]);
4127 }
4128 }
4129 else
4130 {
4131 for(int32_t i=0; i<176; i++)
4132 {
4133 overcombotranslucent(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i],TheMaps[currmap*MAPSCRS+s].layeropacity[k]);
4134 }
4135 }
4136 }
4137 }
4138 }
4139
4140 stretch_blit(_screen_draw_buffer, mappic, 0, 0, 256, 176,
4141 x<<(8-mapres2), (y*176)>>mapres2, 256>>mapres2, 176>>mapres2);
4142 }
4143
4144 }
4145
4146 save_bitmap(buf,mappic,RAMpal);
4147 destroy_bitmap(mappic);
4148 destroy_bitmap(_screen_draw_buffer);
4149 return D_O_K;
4150 }
4151 */
4152
4153 14 void f_Quit(int32_t type)
4154 {
4155
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
14 if(type==qQUIT && !Playing)
4156 return;
4157
4158 14 bool from_menu = is_sys_pal;
4159
4160
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!from_menu)
4161 {
4162 14 music_pause();
4163 14 pause_all_sfx();
4164 14 }
4165 14 enter_sys_pal();
4166 14 clear_keybuf();
4167
4168
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if (replay_is_active() && replay_get_version() <= 9)
4169 14 replay_poll();
4170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if (replay_is_replaying())
4171 14 replay_peek_quit();
4172
4173
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if (!replay_is_replaying())
4174 switch(type)
4175 {
4176 case qQUIT:
4177 onQuit();
4178 break;
4179
4180 case qRESET:
4181 onReset();
4182 break;
4183
4184 case qEXIT:
4185 onExit();
4186 break;
4187 }
4188
4189
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(Quit)
4190 {
4191 14 kill_sfx();
4192 14 music_stop();
4193 14 exit_sys_pal();
4194 14 update_hw_screen();
4195 14 }
4196 else
4197 {
4198 exit_sys_pal();
4199 if(!from_menu)
4200 {
4201 music_resume();
4202 resume_all_sfx();
4203 }
4204 }
4205
4206
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!from_menu)
4207 14 show_mouse(NULL);
4208 14 eat_buttons();
4209
4210 14 zc_readrawkey(KEY_ESC);
4211
4212 14 zc_readrawkey(KEY_ENTER);
4213 14 }
4214
4215 //----------------------------------------------------------------
4216
4217 int32_t onNoWalls()
4218 {
4219 cheats_enqueue(Cheat::Walls);
4220 return D_O_K;
4221 }
4222
4223 int32_t onIgnoreSideview()
4224 {
4225 cheats_enqueue(Cheat::IgnoreSideView);
4226 return D_O_K;
4227 }
4228
4229 4800616 int32_t input_idle(bool checkmouse)
4230 {
4231 static int32_t mx, my, mz, mb;
4232
4233
4/6
✓ Branch 0 taken 4800616 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1110232 times.
✓ Branch 3 taken 3690384 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1110232 times.
5910848 if(keypressed() || zc_key_pressed() ||
4234
4/8
✓ Branch 0 taken 1110232 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1110232 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1110232 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1110232 times.
✗ Branch 7 not taken.
1110232 (checkmouse && (mx != mouse_x || my != mouse_y || mz != mouse_z || mb != mouse_b)))
4235 {
4236 3690384 idle_count = 0;
4237
4238
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3690384 times.
3690384 if(active_count < MAX_ACTIVE)
4239 {
4240 3690384 ++active_count;
4241 3690384 }
4242 3690384 }
4243
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1110232 times.
1110232 else if(idle_count < MAX_IDLE)
4244 {
4245 1110232 ++idle_count;
4246 1110232 active_count = 0;
4247 1110232 }
4248
4249 4800616 mx = mouse_x;
4250 4800616 my = mouse_y;
4251 4800616 mz = mouse_z;
4252 4800616 mb = mouse_b;
4253
4254 4800616 return idle_count;
4255 }
4256
4257 int32_t onGoFast()
4258 {
4259 cheats_enqueue(Cheat::Fast);
4260 return D_O_K;
4261 }
4262
4263 int32_t onKillCheat()
4264 {
4265 cheats_enqueue(Cheat::Kill);
4266 return D_O_K;
4267 }
4268
4269 int32_t onShowLayer0()
4270 {
4271 show_layer_0 = !show_layer_0;
4272 return D_O_K;
4273 }
4274 int32_t onShowLayer1()
4275 {
4276 show_layer_1 = !show_layer_1;
4277 return D_O_K;
4278 }
4279 int32_t onShowLayer2()
4280 {
4281 show_layer_2 = !show_layer_2;
4282 return D_O_K;
4283 }
4284 int32_t onShowLayer3()
4285 {
4286 show_layer_3 = !show_layer_3;
4287 return D_O_K;
4288 }
4289 int32_t onShowLayer4()
4290 {
4291 show_layer_4 = !show_layer_4;
4292 return D_O_K;
4293 }
4294 int32_t onShowLayer5()
4295 {
4296 show_layer_5 = !show_layer_5;
4297 return D_O_K;
4298 }
4299 int32_t onShowLayer6()
4300 {
4301 show_layer_6 = !show_layer_6;
4302 return D_O_K;
4303 }
4304 int32_t onShowLayerO()
4305 {
4306 show_layer_over=!show_layer_over;
4307 return D_O_K;
4308 }
4309 int32_t onShowLayerP()
4310 {
4311 show_layer_push=!show_layer_push;
4312 return D_O_K;
4313 }
4314 int32_t onShowLayerS()
4315 {
4316 show_sprites=!show_sprites;
4317 return D_O_K;
4318 }
4319 int32_t onShowLayerF()
4320 {
4321 show_ffcs=!show_ffcs;
4322 return D_O_K;
4323 }
4324 int32_t onShowLayerW()
4325 {
4326 show_walkflags=!show_walkflags;
4327 return D_O_K;
4328 }
4329 int32_t onShowLayerE()
4330 {
4331 show_effectflags=!show_effectflags;
4332 return D_O_K;
4333 }
4334 int32_t onShowFFScripts()
4335 {
4336 show_ff_scripts=!show_ff_scripts;
4337 return D_O_K;
4338 }
4339 int32_t onShowHitboxes()
4340 {
4341 show_hitboxes=!show_hitboxes;
4342 return D_O_K;
4343 }
4344
4345 int32_t onLightSwitch()
4346 {
4347 cheats_enqueue(Cheat::Light);
4348 return D_O_K;
4349 }
4350
4351 int32_t onGoTo();
4352 int32_t onGoToComplete();
4353
4354 4800616 void syskeys()
4355 {
4356 4800616 update_system_keys();
4357
4358 int32_t oldtitle_version;
4359
4360
1/2
✓ Branch 0 taken 4800616 times.
✗ Branch 1 not taken.
4800616 if(close_button_quit)
4361 {
4362 close_button_quit=false;
4363 f_Quit(qEXIT);
4364 }
4365
4366 4800616 poll_joystick();
4367
4368
2/10
✓ Branch 0 taken 4800616 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4800616 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
4800616 if(rMbtn() || (gui_mouse_b() && !mouse_down && ClickToFreeze &&!disableClickToFreeze))
4369 {
4370 oldtitle_version=title_version;
4371 System();
4372 }
4373
4374 4800616 mouse_down=gui_mouse_b();
4375
4376
1/2
✓ Branch 0 taken 4800616 times.
✗ Branch 1 not taken.
4800616 if(zc_read_system_key(KEY_F1))
4377 {
4378 if(zc_get_system_key(KEY_ZC_LCONTROL) || zc_get_system_key(KEY_ZC_RCONTROL))
4379 {
4380 halt=!halt;
4381 //zinit.subscreen=(zinit.subscreen+1)%ssdtMAX;
4382 }
4383 else
4384 {
4385 Throttlefps=!Throttlefps;
4386 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
4387 logic_counter=0;
4388 }
4389 }
4390
4391 // if(zc_readkey(KEY_F1)) Vsync=!Vsync;
4392 /*
4393 if(zc_readkey(KEY_F1)) set_bit(QHeader.rules4,qr4_NEWENEMYTILES,
4394 1-((get_bit(QHeader.rules4,qr4_NEWENEMYTILES))));
4395 */
4396
4397
1/2
✓ Branch 0 taken 4800616 times.
✗ Branch 1 not taken.
4800616 if(zc_read_system_key(KEY_F2))
4398 {
4399 ShowFPS=!ShowFPS;
4400 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
4401 }
4402
4403
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4800616 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4800616 if(zc_read_system_key(KEY_F3) && Playing) Paused=!Paused;
4404
4405
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4800616 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4800616 if(zc_read_system_key(KEY_F4) && Playing)
4406 {
4407 Paused=true;
4408 Advance=true;
4409 }
4410
4411
1/2
✓ Branch 0 taken 4800616 times.
✗ Branch 1 not taken.
4800616 if(zc_read_system_key(KEY_F6)) onTryQuit();
4412
4413 #ifndef ALLEGRO_MACOSX
4414
1/2
✓ Branch 0 taken 4800616 times.
✗ Branch 1 not taken.
4800616 if(zc_read_system_key(KEY_F9)) f_Quit(qRESET);
4415
4416
1/2
✓ Branch 0 taken 4800616 times.
✗ Branch 1 not taken.
4800616 if(zc_read_system_key(KEY_F10)) f_Quit(qEXIT);
4417 #else
4418 if(zc_read_system_key(KEY_F7)) f_Quit(qRESET);
4419
4420 if(zc_read_system_key(KEY_F8)) f_Quit(qEXIT);
4421 #endif
4422
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 4800616 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
4800616 if(zc_read_system_key(KEY_F5)&&(Playing && currscr<128 && DMaps[currdmap].flags&dmfVIEWMAP)) onSaveMapPic();
4423
4424
1/2
✓ Branch 0 taken 4800616 times.
✗ Branch 1 not taken.
4800616 if (zc_read_system_key(KEY_F12))
4425 {
4426 onSnapshot();
4427 }
4428
4429
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4800616 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4800616 if(debug_enabled && zc_read_system_key(KEY_TAB))
4430 set_debug(!get_debug());
4431
4432
3/4
✓ Branch 0 taken 4800616 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20470 times.
✓ Branch 3 taken 4780146 times.
4800616 if(get_debug() || cheat>=1)
4433 {
4434
1/2
✓ Branch 0 taken 20470 times.
✗ Branch 1 not taken.
20470 if( CheatModifierKeys() )
4435 {
4436 if(zc_readkey(KEY_ASTERISK) || zc_readkey(KEY_H)) cheats_enqueue(Cheat::Life, game->get_maxlife());
4437
4438 if(zc_readkey(KEY_SLASH_PAD) || zc_readkey(KEY_M)) cheats_enqueue(Cheat::Magic, game->get_maxmagic());
4439
4440 if(zc_readkey(KEY_R)) cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
4441
4442 if(zc_readkey(KEY_B))
4443 {
4444 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
4445 }
4446
4447 if(zc_readkey(KEY_A))
4448 {
4449 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
4450 }
4451 }
4452 20470 }
4453
4454
3/4
✓ Branch 0 taken 4800616 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20470 times.
✓ Branch 3 taken 4780146 times.
4800616 if(get_debug() || cheat>=2)
4455 {
4456
1/2
✓ Branch 0 taken 20470 times.
✗ Branch 1 not taken.
20470 if( CheatModifierKeys() )
4457 {
4458 if(rI())
4459 {
4460 cheats_enqueue(Cheat::Clock);
4461 }
4462 }
4463 20470 }
4464
4465
3/4
✓ Branch 0 taken 4800616 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20470 times.
✓ Branch 3 taken 4780146 times.
4800616 if(get_debug() || cheat>=4)
4466 {
4467
1/2
✓ Branch 0 taken 20470 times.
✗ Branch 1 not taken.
20470 if( CheatModifierKeys() )
4468 {
4469 if(rF11())
4470 {
4471 cheats_enqueue(Cheat::Walls);
4472 }
4473
4474 if(rQ())
4475 {
4476 cheats_enqueue(Cheat::Fast);
4477 }
4478
4479 if(zc_readkey(KEY_F))
4480 {
4481 cheats_enqueue(Cheat::Freeze);
4482 }
4483
4484 if(zc_readkey(KEY_G)) onGoToComplete();
4485
4486 if(zc_readkey(KEY_0)) onShowLayer0();
4487
4488 if(zc_readkey(KEY_1)) onShowLayer1();
4489
4490 if(zc_readkey(KEY_2)) onShowLayer2();
4491
4492 if(zc_readkey(KEY_3)) onShowLayer3();
4493
4494 if(zc_readkey(KEY_4)) onShowLayer4();
4495
4496 if(zc_readkey(KEY_5)) onShowLayer5();
4497
4498 if(zc_readkey(KEY_6)) onShowLayer6();
4499
4500 //if(zc_readkey(KEY_7)) onShowLayerO();
4501 if(zc_readkey(KEY_7)) onShowLayerF();
4502
4503 if(zc_readkey(KEY_8)) onShowLayerS();
4504
4505 if(zc_readkey(KEY_W)) onShowLayerW();
4506
4507 if(zc_readkey(KEY_L)) cheats_enqueue(Cheat::Light);
4508
4509 if(zc_readkey(KEY_V)) cheats_enqueue(Cheat::IgnoreSideView);
4510
4511 if(zc_readkey(KEY_K)) cheats_enqueue(Cheat::Kill);
4512 if(zc_readkey(KEY_O)) onShowLayerO();
4513 if(zc_readkey(KEY_P)) onShowLayerP();
4514 if(zc_readkey(KEY_C)) onShowHitboxes();
4515 if(zc_readkey(KEY_F)) onShowFFScripts();
4516 }
4517 20470 }
4518
4519
1/2
✓ Branch 0 taken 4800616 times.
✗ Branch 1 not taken.
4800616 if(volkeys)
4520 {
4521 if(zc_read_system_key(KEY_PGUP)) master_volume(-1,midi_volume+8);
4522
4523 if(zc_read_system_key(KEY_PGDN)) master_volume(-1,midi_volume==255?248:midi_volume-8);
4524
4525 if(zc_read_system_key(KEY_HOME)) master_volume(digi_volume+8,-1);
4526
4527 if(zc_read_system_key(KEY_END)) master_volume(digi_volume==255?248:digi_volume-8,-1);
4528 }
4529
4530
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4800616 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4800616 if(!get_debug() || !SystemKeys || replay_is_replaying())
4531 4800616 goto bottom;
4532
4533 if(zc_readkey(KEY_D))
4534 {
4535 details = !details;
4536 rectfill(screen,0,0,319,7,BLACK);
4537 rectfill(screen,0,8,31,239,BLACK);
4538 rectfill(screen,288,8,319,239,BLACK);
4539 rectfill(screen,32,232,287,239,BLACK);
4540 }
4541
4542 if(zc_readkey(KEY_P)) Paused=!Paused;
4543
4544 //if(zc_readkey(KEY_P)) centerHero();
4545 if(zc_readkey(KEY_A))
4546 {
4547 Paused=true;
4548 Advance=true;
4549 }
4550
4551 if(zc_readkey(KEY_G)) db=(db==999)?0:999;
4552 #ifndef ALLEGRO_MACOSX
4553 if(zc_readkey(KEY_F8)) Showpal=!Showpal;
4554
4555 if(zc_readkey(KEY_F7))
4556 {
4557 Matrix(ss_speed, ss_density, 0);
4558 game_pal();
4559 }
4560 #else
4561 // The reason these are different on Mac in the first place is that
4562 // the OS doesn't let us use F9 and F10...
4563 if(zc_readkey(KEY_F10)) Showpal=!Showpal;
4564
4565 if(zc_readkey(KEY_F9))
4566 {
4567 Matrix(ss_speed, ss_density, 0);
4568 game_pal();
4569 }
4570 #endif
4571 if(zc_readkey(KEY_PLUS_PAD) || zc_readkey(KEY_EQUALS))
4572 {
4573 //change containers
4574 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4575 {
4576 //magic containers
4577 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4578 {
4579 game->set_maxmagic(zc_min(game->get_maxmagic()+game->get_mp_per_block(),game->get_mp_per_block()*8));
4580 }
4581 else
4582 {
4583 game->set_maxlife(zc_min(game->get_maxlife()+game->get_hp_per_heart(),game->get_hp_per_heart()*24));
4584 }
4585 }
4586 else
4587 {
4588 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4589 {
4590 game->set_magic(zc_min(game->get_magic()+1,game->get_maxmagic()));
4591 }
4592 else
4593 {
4594 game->set_life(zc_min(game->get_life()+1,game->get_maxlife()));
4595 }
4596 }
4597 }
4598
4599 if(zc_readkey(KEY_MINUS_PAD) || zc_readkey(KEY_MINUS))
4600 {
4601 //change containers
4602 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4603 {
4604 //magic containers
4605 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4606 {
4607 game->set_maxmagic(zc_max(game->get_maxmagic()-game->get_mp_per_block(),0));
4608 game->set_magic(zc_min(game->get_maxmagic(), game->get_magic()));
4609 //heart containers
4610 }
4611 else
4612 {
4613 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),game->get_hp_per_heart()));
4614 game->set_life(zc_min(game->get_maxlife(), game->get_life()));
4615 }
4616 }
4617 else
4618 {
4619 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4620 {
4621 game->set_magic(zc_max(game->get_magic()-1,0));
4622 }
4623 else
4624 {
4625 game->set_life(zc_max(game->get_life()-1,0));
4626 }
4627 }
4628 }
4629
4630 if(zc_readkey(KEY_COMMA)) jukebox(currmidi-1);
4631
4632 if(zc_readkey(KEY_STOP)) jukebox(currmidi+1);
4633
4634 verifyBothWeapons();
4635
4636 bottom:
4637
4638
1/2
✓ Branch 0 taken 4800616 times.
✗ Branch 1 not taken.
4800616 if(input_idle(true) > after_time())
4639 {
4640 Matrix(ss_speed, ss_density, 0);
4641 game_pal();
4642 }
4643 4800616 }
4644
4645 330136 void checkQuitKeys()
4646 {
4647 #ifndef ALLEGRO_MACOSX
4648
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 330136 times.
330136 if(key[KEY_F9]) f_Quit(qRESET);
4649
4650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 330136 times.
330136 if(key[KEY_F10]) f_Quit(qEXIT);
4651 #else
4652 if(key[KEY_F7]) f_Quit(qRESET);
4653
4654 if(key[KEY_F8]) f_Quit(qEXIT);
4655 #endif
4656 330136 }
4657
4658 61410 bool CheatModifierKeys()
4659 {
4660 // Cheats are replayed via the X cheat step, no need to check for keyboard input
4661 // to trigger cheats.
4662
1/2
✓ Branch 0 taken 61410 times.
✗ Branch 1 not taken.
61410 if (replay_is_replaying())
4663 61410 return false;
4664
4665 if ( ( cheat_modifier_keys[0] > 0 && key[cheat_modifier_keys[0]] ) ||
4666 ( cheat_modifier_keys[1] > 0 && key[cheat_modifier_keys[1]] ) ||
4667 (cheat_modifier_keys[0] <= 0 && cheat_modifier_keys[1] <= 0))
4668 {
4669 if ( ( cheat_modifier_keys[2] <= 0 || key[cheat_modifier_keys[2]] ) ||
4670 ( cheat_modifier_keys[3] > 0 && key[cheat_modifier_keys[3]] ) ||
4671 (cheat_modifier_keys[2] <= 0 && cheat_modifier_keys[3] <= 0))
4672 {
4673 return true;
4674 }
4675 }
4676 return false;
4677 61410 }
4678
4679 //99:05:54, for some reason?
4680 #define OLDMAXTIME 21405240
4681 //9000:00:00, the highest even-thousand hour fitting within 32b signed. This is 375 *DAYS*.
4682 #define MAXTIME 1944000000
4683
4684 4800661 void advanceframe(bool allowwavy, bool sfxcleanup, bool allowF6Script)
4685 {
4686
2/2
✓ Branch 0 taken 4539250 times.
✓ Branch 1 taken 261411 times.
4800661 if(zcmusic!=NULL)
4687 {
4688 261411 zcmusic_poll();
4689 261411 }
4690
4691 4800661 updatescr(allowwavy);
4692
4693
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4800661 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4800661 times.
4800661 while(Paused && !Advance && !Quit)
4694 {
4695 // have to call this, otherwise we'll get an infinite loop
4696 syskeys();
4697 if(allowF6Script)
4698 {
4699 FFCore.runF6Engine();
4700 }
4701 throttleFPS();
4702
4703 #ifdef _WIN32
4704
4705 if(use_dwm_flush)
4706 {
4707 do_DwmFlush();
4708 }
4709
4710 #endif
4711
4712 // to keep music playing
4713 if(zcmusic!=NULL)
4714 {
4715 zcmusic_poll();
4716 }
4717
4718 update_hw_screen();
4719 }
4720
4721
2/2
✓ Branch 0 taken 4800625 times.
✓ Branch 1 taken 36 times.
4800661 if(Quit)
4722 36 return;
4723
4724
3/4
✓ Branch 0 taken 4732881 times.
✓ Branch 1 taken 67744 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4732881 times.
4800625 if(Playing && game->get_time()<unsigned(get_bit(quest_rules,qr_GREATER_MAX_TIME) ? MAXTIME : OLDMAXTIME))
4725 4732881 game->change_time(1);
4726
4727 4800625 Advance=false;
4728
4729
2/4
✓ Branch 0 taken 4800625 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4800625 times.
4800625 if (!replay_is_active() || replay_get_version() >= 11)
4730 for (int i = 0; i < ZC_CONTROL_STATES; i++)
4731 down_control_states[i] = raw_control_state[i];
4732
4733
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 4800616 times.
4800625 if (replay_is_active())
4734 {
4735
2/2
✓ Branch 0 taken 1270454 times.
✓ Branch 1 taken 3530162 times.
4800616 if (replay_get_version() >= 3)
4736 3530162 replay_poll();
4737
4738
5/6
✓ Branch 0 taken 4800616 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1379964 times.
✓ Branch 3 taken 3420652 times.
✓ Branch 4 taken 100535 times.
✓ Branch 5 taken 1279429 times.
4800616 if (replay_get_version() >= 11 || (replay_get_version() >= 6 && replay_get_version() < 8))
4739 100535 replay_peek_input();
4740 4800616 }
4741
4742 4800625 load_control_called_this_frame = false;
4743
4744 4800625 poll_keyboard();
4745 4800625 update_keys();
4746
4747 4800625 ++frame;
4748
4749
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 4800616 times.
4800625 if (replay_is_replaying())
4750 4800616 replay_do_cheats();
4751 4800625 syskeys();
4752
4753 // The mouse variables can change from the mouse thread at anytime during a frame,
4754 // so save the result at the start so that replaying is consistent.
4755 4800625 script_mouse_x = gui_mouse_x();
4756 4800625 script_mouse_y = gui_mouse_y();
4757 4800625 script_mouse_z = mouse_z;
4758 4800625 script_mouse_b = mouse_b;
4759
4760 // Cheats used via the System menu (called by syskeys) will call cheats_enqueue. syskeys
4761 // is called just above, and in the paused loop above, so the queue-and-defer-slightly
4762 // approach here means it doesn't matter which call adds the cheat.
4763 4800625 cheats_execute_queued();
4764
4765
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 4800616 times.
4800625 if (replay_is_replaying())
4766 4800616 replay_peek_quit();
4767
2/2
✓ Branch 0 taken 4800611 times.
✓ Branch 1 taken 14 times.
4800625 if (GameFlags & GAMEFLAG_TRYQUIT)
4768 14 replay_step_quit(0);
4769
2/2
✓ Branch 0 taken 1469 times.
✓ Branch 1 taken 4799156 times.
4800625 if(allowF6Script)
4770 {
4771 4799156 FFCore.runF6Engine();
4772 4799156 }
4773
2/2
✓ Branch 0 taken 4800484 times.
✓ Branch 1 taken 141 times.
4800625 if (Quit)
4774 141 replay_step_quit(Quit);
4775 // Someday... maybe install a Turbo button here?
4776 4800625 throttleFPS();
4777
4778 #ifdef _WIN32
4779
4780 if(use_dwm_flush)
4781 {
4782 do_DwmFlush();
4783 }
4784
4785 #endif
4786
4787 //textprintf_ex(screen,font,0,72,254,BLACK,"%d %d", lastentrance, lastentrance_dmap);
4788
2/2
✓ Branch 0 taken 6449 times.
✓ Branch 1 taken 4794176 times.
4800625 if(sfxcleanup)
4789 4794176 sfx_cleanup();
4790 4800661 }
4791
4792 12 void zapout()
4793 {
4794 12 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4795 12 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4796
4797 12 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4798 12 script_drawing_commands.Clear();
4799
4800 // zap out
4801
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 288 times.
300 for(int32_t i=1; i<=24; i++)
4802 {
4803 288 draw_fuzzy(i);
4804 288 advanceframe(true);
4805
4806
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 288 times.
288 if(Quit)
4807 {
4808 break;
4809 }
4810 288 }
4811 12 }
4812
4813 12 void zapin()
4814 {
4815 12 FFCore.warpScriptCheck();
4816 12 draw_screen(tmpscr);
4817 12 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4818 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4819 12 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4820
4821 // zap out
4822 12 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4823
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 288 times.
300 for(int32_t i=24; i>=1; i--)
4824 {
4825 288 draw_fuzzy(i);
4826 288 advanceframe(true);
4827
4828
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 288 times.
288 if(Quit)
4829 {
4830 break;
4831 }
4832 288 }
4833 12 }
4834
4835
4836 23 void wavyout(bool showhero)
4837 {
4838 23 draw_screen(tmpscr, showhero);
4839 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4840
4841 23 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4842 23 clear_to_color(wavebuf,0);
4843 23 blit(framebuf,wavebuf,0,0,16,0,256,224);
4844
4845 static PALETTE wavepal;
4846
4847 int32_t ofs;
4848 23 int32_t amplitude=8;
4849
4850 23 int32_t wavelength=4;
4851 23 double palpos=0, palstep=4, palstop=126;
4852
4853 23 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4854
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 966 times.
989 for(int32_t i=0; i<168; i+=wavelength)
4855 {
4856
2/2
✓ Branch 0 taken 247296 times.
✓ Branch 1 taken 966 times.
248262 for(int32_t l=0; l<256; l++)
4857 {
4858 247296 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4859 247296 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4860 247296 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4861 247296 }
4862
4863 966 palpos+=palstep;
4864
4865
1/2
✓ Branch 0 taken 966 times.
✗ Branch 1 not taken.
966 if(palpos>=0)
4866 {
4867 966 hw_palette = &wavepal;
4868 966 update_hw_pal = true;
4869 966 }
4870 else
4871 {
4872 hw_palette = &RAMpal;
4873 update_hw_pal = true;
4874 }
4875
4876
2/2
✓ Branch 0 taken 162288 times.
✓ Branch 1 taken 966 times.
163254 for(int32_t j=0; j+playing_field_offset<224; j++)
4877 {
4878
2/2
✓ Branch 0 taken 41545728 times.
✓ Branch 1 taken 162288 times.
41708016 for(int32_t k=0; k<256; k++)
4879 {
4880 41545728 ofs=0;
4881
4882
4/4
✓ Branch 0 taken 20278272 times.
✓ Branch 1 taken 21267456 times.
✓ Branch 2 taken 10139136 times.
✓ Branch 3 taken 10139136 times.
41545728 if((j<i)&&(j&1))
4883 {
4884 10139136 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4885 10139136 }
4886
4887 41545728 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4888 41545728 }
4889 162288 }
4890
4891 966 advanceframe(true);
4892
4893 // animate_combos();
4894
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 966 times.
966 if(Quit)
4895 break;
4896 966 }
4897
4898 23 destroy_bitmap(wavebuf);
4899 23 }
4900
4901 23 void wavyin()
4902 {
4903 23 draw_screen(tmpscr);
4904 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4905
4906 23 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4907 23 clear_to_color(wavebuf,0);
4908 23 blit(framebuf,wavebuf,0,0,16,0,256,224);
4909
4910 static PALETTE wavepal;
4911
4912 //Breaks dark rooms.
4913 //In any case I don't think we need this, since palette is already loaded in doWarp() (famous last words...) -DD
4914 /*
4915 loadfullpal();
4916 loadlvlpal(DMaps[currdmap].color);
4917 ringcolor(false);
4918 */
4919 23 refreshpal=false;
4920 int32_t ofs;
4921 23 int32_t amplitude=8;
4922 23 int32_t wavelength=4;
4923 23 double palpos=168, palstep=4, palstop=126;
4924
4925 23 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4926
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 966 times.
989 for(int32_t i=0; i<168; i+=wavelength)
4927 {
4928
2/2
✓ Branch 0 taken 247296 times.
✓ Branch 1 taken 966 times.
248262 for(int32_t l=0; l<256; l++)
4929 {
4930 247296 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4931 247296 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4932 247296 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4933 247296 }
4934
4935 966 palpos-=palstep;
4936
4937
1/2
✓ Branch 0 taken 966 times.
✗ Branch 1 not taken.
966 if(palpos>=0)
4938 {
4939 966 hw_palette = &wavepal;
4940 966 update_hw_pal = true;
4941 966 }
4942 else
4943 {
4944 hw_palette = &RAMpal;
4945 update_hw_pal = true;
4946 }
4947
4948
2/2
✓ Branch 0 taken 162288 times.
✓ Branch 1 taken 966 times.
163254 for(int32_t j=0; j+playing_field_offset<224; j++)
4949 {
4950
2/2
✓ Branch 0 taken 41545728 times.
✓ Branch 1 taken 162288 times.
41708016 for(int32_t k=0; k<256; k++)
4951 {
4952 41545728 ofs=0;
4953
4954
4/4
✓ Branch 0 taken 21020160 times.
✓ Branch 1 taken 20525568 times.
✓ Branch 2 taken 10633728 times.
✓ Branch 3 taken 10386432 times.
41545728 if((j<(167-i))&&(j&1))
4955 {
4956 10386432 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4957 10386432 }
4958
4959 41545728 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4960 41545728 }
4961 162288 }
4962
4963 966 advanceframe(true);
4964 // animate_combos();
4965
4966
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 966 times.
966 if(Quit)
4967 break;
4968 966 }
4969
4970 23 destroy_bitmap(wavebuf);
4971 23 }
4972
4973 1252 void blackscr(int32_t fcnt,bool showsubscr)
4974 {
4975 1252 reset_pal_cycling();
4976 1252 script_drawing_commands.Clear();
4977
4978 1252 FFCore.warpScriptCheck();
4979 1252 bool showtime = game->should_show_time();
4980
2/2
✓ Branch 0 taken 1252 times.
✓ Branch 1 taken 37490 times.
38742 while(fcnt>0)
4981 {
4982 37490 clear_bitmap(framebuf);
4983
4984
2/2
✓ Branch 0 taken 9360 times.
✓ Branch 1 taken 28130 times.
37490 if(showsubscr)
4985 {
4986 28130 put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,showtime,sspUP);
4987
3/4
✓ Branch 0 taken 28130 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 750 times.
✓ Branch 3 taken 27380 times.
28130 if(get_bit(quest_rules, qr_SCRIPTDRAWSINWARPS) || (get_bit(quest_rules, qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN)))
4988 {
4989 750 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
4990 750 }
4991 28130 }
4992
4993 37490 advanceframe(true);
4994
4995
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37490 times.
37490 if(Quit)
4996 break;
4997
4998 37490 --fcnt;
4999 }
5000 1252 }
5001
5002 332 void openscreen(int32_t shape)
5003 {
5004 332 reset_pal_cycling();
5005 332 black_opening_count=0;
5006
5007
3/4
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 234 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 98 times.
332 if(COOLSCROLL || shape>-1)
5008 {
5009 234 open_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5010 234 return;
5011 }
5012 else
5013 {
5014 98 Hero.setDontDraw(true);
5015 98 show_subscreen_dmap_dots=false;
5016 98 show_subscreen_numbers=false;
5017 // show_subscreen_items=false;
5018 98 show_subscreen_life=false;
5019 }
5020
5021 98 int32_t x=128;
5022
5023 98 FFCore.warpScriptCheck();
5024
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 7840 times.
7938 for(int32_t i=0; i<80; i++)
5025 {
5026 7840 draw_screen(tmpscr);
5027 //? draw_screen already draws the subscreen -DD
5028 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
5029 7840 x=128-(((i*128/80)/8)*8);
5030
5031
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7840 times.
7840 if(x>0)
5032 {
5033 7840 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5034 7840 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5035 7840 }
5036
5037 7840 advanceframe(true);
5038
5039
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7840 times.
7840 if(Quit)
5040 {
5041 break;
5042 }
5043 7840 }
5044
5045 98 Hero.setDontDraw(false);
5046 98 show_subscreen_items=true;
5047 98 show_subscreen_dmap_dots=true;
5048 332 }
5049
5050 void closescreen(int32_t shape)
5051 {
5052 reset_pal_cycling();
5053 black_opening_count=0;
5054
5055 if(COOLSCROLL || shape>-1)
5056 {
5057 close_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5058 return;
5059 }
5060 else
5061 {
5062 Hero.setDontDraw(true);
5063 show_subscreen_dmap_dots=false;
5064 show_subscreen_numbers=false;
5065 // show_subscreen_items=false;
5066 show_subscreen_life=false;
5067 }
5068
5069 int32_t x=128;
5070
5071 FFCore.warpScriptCheck();
5072 for(int32_t i=79; i>=0; --i)
5073 {
5074 draw_screen(tmpscr);
5075 //? draw_screen already draws the subscreen -DD
5076 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
5077 x=128-(((i*128/80)/8)*8);
5078
5079 if(x>0)
5080 {
5081 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5082 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5083 }
5084
5085 advanceframe(true);
5086
5087 if(Quit)
5088 {
5089 break;
5090 }
5091 }
5092
5093 Hero.setDontDraw(false);
5094 show_subscreen_items=true;
5095 show_subscreen_dmap_dots=true;
5096 }
5097
5098 84 int32_t TriforceCount()
5099 {
5100 84 int32_t c=0;
5101
5102
2/2
✓ Branch 0 taken 672 times.
✓ Branch 1 taken 84 times.
756 for(int32_t i=1; i<=8; i++)
5103
2/2
✓ Branch 0 taken 298 times.
✓ Branch 1 taken 374 times.
1046 if(game->lvlitems[i]&liTRIFORCE)
5104 374 ++c;
5105
5106 84 return c;
5107 }
5108
5109 int32_t onCustomGame()
5110 {
5111 int32_t file = getsaveslot();
5112
5113 if(file < 0)
5114 return D_O_K;
5115
5116 bool ret = (custom_game(file)!=0);
5117 return ret ? D_CLOSE : D_O_K;
5118 }
5119
5120 int32_t onContinue()
5121 {
5122 return D_CLOSE;
5123 }
5124
5125 int32_t onEsc() // Unused?? -L
5126 {
5127 return zc_getrawkey(KEY_ESC, true)?D_CLOSE:D_O_K;
5128 }
5129
5130 int32_t onVsync()
5131 {
5132 Throttlefps = !Throttlefps;
5133 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
5134 return D_O_K;
5135 }
5136
5137 int32_t onWinPosSave()
5138 {
5139 SaveWinPos = !SaveWinPos;
5140 zc_set_config(cfg_sect,"save_window_position",(int32_t)SaveWinPos);
5141 return D_O_K;
5142 }
5143
5144 int32_t onClickToFreeze()
5145 {
5146 ClickToFreeze = !ClickToFreeze;
5147 zc_set_config(cfg_sect,"clicktofreeze", (int32_t)ClickToFreeze);
5148 return D_O_K;
5149 }
5150
5151 int32_t OnSaveZCConfig()
5152 {
5153 if(jwin_alert3(
5154 "Save Configuration",
5155 "Are you sure that you wish to save your present configuration settings?",
5156 "This will overwrite your prior settings!",
5157 NULL,
5158 "&Yes",
5159 "&No",
5160 NULL,
5161 'y',
5162 'n',
5163 0,
5164 lfont) == 1)
5165 {
5166 save_game_configs();
5167 return D_O_K;
5168 }
5169 else return D_O_K;
5170 }
5171
5172 int32_t OnnClearQuestDir()
5173 {
5174 if(jwin_alert3(
5175 "Clear Current Directory Cache",
5176 "Are you sure that you wish to clear the current cached directory?",
5177 "This will default the current directory to the ROOT for this instance of ZC Player!",
5178 NULL,
5179 "&Yes",
5180 "&No",
5181 NULL,
5182 'y',
5183 'n',
5184 0,
5185 lfont) == 1)
5186 {
5187 zc_set_config("zeldadx","win_qst_dir","");
5188 flush_config_file();
5189 strcpy(qstdir,"");
5190 #ifdef __EMSCRIPTEN__
5191 em_sync_fs();
5192 #endif
5193 return D_O_K;
5194 }
5195 else return D_O_K;
5196 }
5197
5198
5199 int32_t onConsoleZASM()
5200 {
5201 if ( !zasm_debugger )
5202 {
5203 AlertDialog("WARNING: ZASM Debugger",
5204 "Enabling this will open the ZASM Debugger Console"
5205 "\nThis will likely grind ZC to a halt with lag."
5206 "\nTo make any use of this, it is suggested that you read"
5207 "\nthe documentation for 'void Breakpoint(char[] string);'"
5208 " in 'ZScript_Additions.txt'"
5209 "\nThis is not recommended for normal users,"
5210 " and is only intended for ZC developers,"
5211 "\nor quest developers coding directly in ZASM"
5212 "\nAre you sure that you wish to open the ZASM Debugger?",
5213 [&](bool ret,bool)
5214 {
5215 if(ret)
5216 {
5217 FFCore.ZASMPrint(true);
5218 }
5219 }).show();
5220 return D_O_K;
5221 }
5222 else
5223 {
5224 FFCore.ZASMPrint(false);
5225 return D_O_K;
5226 }
5227 }
5228
5229
5230 int32_t onConsoleZScript()
5231 {
5232 if ( !zscript_debugger )
5233 {
5234 AlertDialog("ZScript Debugger",
5235 "Enabling this will open the ZScript Debugger Console"
5236 "\nThis will display any messages logged by scripts,"
5237 " including script errors."
5238 "\nAre you sure that you wish to open the ZScript Debugger?",
5239 [&](bool ret,bool)
5240 {
5241 if(ret)
5242 {
5243 FFCore.ZScriptConsole(true);
5244 }
5245 }).show();
5246 return D_O_K;
5247 }
5248 else
5249 {
5250 FFCore.ZScriptConsole(false);
5251 return D_O_K;
5252 }
5253 }
5254
5255 int32_t onClrConsoleOnLoad()
5256 {
5257 clearConsoleOnLoad = !clearConsoleOnLoad;
5258 zc_set_config("CONSOLE","clear_console_on_load",clearConsoleOnLoad?1:0);
5259 return D_O_K;
5260 }
5261
5262
5263 int32_t onFrameSkip()
5264 {
5265 FrameSkip = !FrameSkip;
5266 return D_O_K;
5267 }
5268
5269 int32_t onSaveDragResize()
5270 {
5271 SaveDragResize = !SaveDragResize;
5272 zc_set_config(cfg_sect,"save_drag_resize",(int32_t)SaveDragResize);
5273 return D_O_K;
5274 }
5275
5276 int32_t onDragAspect()
5277 {
5278 DragAspect = !DragAspect;
5279 zc_set_config(cfg_sect,"drag_aspect",(int32_t)DragAspect);
5280 return D_O_K;
5281 }
5282
5283 int32_t onTransLayers()
5284 {
5285 TransLayers = !TransLayers;
5286 zc_set_config(cfg_sect,"translayers",(int32_t)TransLayers);
5287 return D_O_K;
5288 }
5289
5290 int32_t onNESquit()
5291 {
5292 NESquit = !NESquit;
5293 zc_set_config(cfg_sect,"fastquit",(int32_t)NESquit);
5294 return D_O_K;
5295 }
5296
5297 int32_t onVolKeys()
5298 {
5299 volkeys = !volkeys;
5300 zc_set_config(sfx_sect,"volkeys",(int32_t)volkeys);
5301 return D_O_K;
5302 }
5303
5304 int32_t onShowFPS()
5305 {
5306 ShowFPS = !ShowFPS;
5307 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
5308 return D_O_K;
5309 }
5310
5311 566472688 bool is_Fkey(int32_t k)
5312 {
5313
2/2
✓ Branch 0 taken 57607392 times.
✓ Branch 1 taken 508865296 times.
566472688 switch(k)
5314 {
5315 case KEY_F1:
5316 case KEY_F2:
5317 case KEY_F3:
5318 case KEY_F4:
5319 case KEY_F5:
5320 case KEY_F6:
5321 case KEY_F7:
5322 case KEY_F8:
5323 case KEY_F9:
5324 case KEY_F10:
5325 case KEY_F11:
5326 case KEY_F12:
5327 57607392 return true;
5328 }
5329
5330 508865296 return false;
5331 566472688 }
5332
5333 void kb_getkey(DIALOG *d)
5334 {
5335 d->flags|=D_SELECTED;
5336
5337 scare_mouse();
5338 jwin_button_proc(MSG_DRAW,d,0);
5339 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 160, 48, FR_WIN);
5340 // text_mode(vc(11));
5341 textout_centre_ex(gui_bmp, font, "Press a key", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5342 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5343 unscare_mouse();
5344
5345 update_hw_screen(true);
5346
5347 clear_keybuf();
5348 int32_t k = next_press_key();
5349 clear_keybuf();
5350
5351 //shnarf
5352 //47=f1
5353 //59=esc
5354 if(k>0 && k<123 && !((k>46)&&(k<60)))
5355 *((int32_t*)d->dp3) = k;
5356
5357
5358 d->flags&=~D_SELECTED;
5359 }
5360
5361
5362 //Used by all keyboard key settings dialogues.
5363 void kb_clearjoystick(DIALOG *d)
5364 {
5365 d->flags|=D_SELECTED;
5366
5367 scare_mouse();
5368 jwin_button_proc(MSG_DRAW,d,0);
5369 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 168, 48, FR_WIN);
5370 // text_mode(vc(11));
5371 textout_centre_ex(gui_bmp, font, "Press any key to clear", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5372 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5373 unscare_mouse();
5374
5375 update_hw_screen(true);
5376
5377 clear_keybuf();
5378 int32_t k = next_press_key();
5379 clear_keybuf();
5380
5381 //shnarf
5382 //47=f1
5383 //59=esc
5384 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5385 // *((int32_t*)d->dp3) = k;
5386 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5387
5388
5389 d->flags&=~D_SELECTED;
5390 }
5391
5392 //Clears key to 0.
5393 //Used by all keyboard key settings dialogues.
5394 void kb_clearkey(DIALOG *d)
5395 {
5396 d->flags|=D_SELECTED;
5397
5398 scare_mouse();
5399 jwin_button_proc(MSG_DRAW,d,0);
5400 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 160, 48, FR_WIN);
5401 // text_mode(vc(11));
5402 textout_centre_ex(gui_bmp, font, "Press any key to clear", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5403 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5404 unscare_mouse();
5405
5406 update_hw_screen(true);
5407
5408 clear_keybuf();
5409 int32_t k = next_press_key();
5410 clear_keybuf();
5411
5412 //shnarf
5413 //47=f1
5414 //59=esc
5415 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5416 // *((int32_t*)d->dp3) = k;
5417 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5418
5419
5420 d->flags&=~D_SELECTED;
5421 }
5422
5423
5424 int32_t d_j_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5425 {
5426 switch(msg)
5427 {
5428 case MSG_KEY:
5429 case MSG_CLICK:
5430
5431 kb_clearjoystick(d);
5432
5433 while(gui_mouse_b())
5434 {
5435 clear_keybuf();
5436 rest(1);
5437 }
5438
5439 return D_REDRAW;
5440 }
5441
5442 return jwin_button_proc(msg,d,c);
5443 }
5444
5445 int32_t d_kbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5446 {
5447 switch(msg)
5448 {
5449 case MSG_KEY:
5450 case MSG_CLICK:
5451
5452 kb_getkey(d);
5453
5454 while(gui_mouse_b()) {
5455 clear_keybuf();
5456 rest(1);
5457 }
5458
5459 return D_REDRAW;
5460 }
5461
5462 return jwin_button_proc(msg,d,c);
5463 }
5464
5465 //Only used in keyboard settings dialogues to clear keys.
5466 int32_t d_k_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5467 {
5468 switch(msg)
5469 {
5470 case MSG_KEY:
5471 case MSG_CLICK:
5472
5473 kb_clearkey(d);
5474
5475 while(gui_mouse_b()) {
5476 clear_keybuf();
5477 rest(1);
5478 }
5479
5480 return D_REDRAW;
5481 }
5482
5483 return jwin_button_proc(msg,d,c);
5484 }
5485
5486 void j_getbtn(DIALOG *d)
5487 {
5488 d->flags|=D_SELECTED;
5489 scare_mouse();
5490 jwin_button_proc(MSG_DRAW,d,0);
5491 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 160, 48, FR_WIN);
5492 // text_mode(vc(11));
5493 int32_t y = gui_bmp->h/2 - 12;
5494 textout_centre_ex(gui_bmp, font, "Press a button", gui_bmp->w/2, y, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5495 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, y+8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5496 textout_centre_ex(gui_bmp, font, "SPACE to disable", gui_bmp->w/2, y+16, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5497 unscare_mouse();
5498
5499 update_hw_screen(true);
5500
5501 int32_t b = next_press_btn();
5502
5503 if(b>=0)
5504 *((int32_t*)d->dp3) = b;
5505
5506 d->flags&=~D_SELECTED;
5507
5508 if (player)
5509 player->joy_on = TRUE;
5510 }
5511
5512 int32_t d_jbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5513 {
5514 switch(msg)
5515 {
5516 case MSG_KEY:
5517 case MSG_CLICK:
5518
5519 j_getbtn(d);
5520
5521 while(gui_mouse_b()) {
5522 rest(1);
5523 clear_keybuf();
5524 }
5525
5526 return D_REDRAW;
5527 }
5528
5529 return jwin_button_proc(msg,d,c);
5530 }
5531
5532 //shnarf
5533 const char *key_str[] =
5534 {
5535 "(none) ", "a ", "b ", "c ",
5536 "d ", "e ", "f ", "g ",
5537 "h ", "i ", "j ", "k ",
5538 "l ", "m ", "n ", "o ",
5539 "p ", "q ", "r ", "s ",
5540 "t ", "u ", "v ", "w ",
5541 "x ", "y ", "z ", "0 ",
5542 "1 ", "2 ", "3 ", "4 ",
5543 "5 ", "6 ", "7 ", "8 ",
5544 "9 ", "num 0 ", "num 1 ", "num 2 ",
5545 "num 3 ", "num 4 ", "num 5 ", "num 6 ",
5546 "num 7 ", "num 8 ", "num 9 ", "f1 ",
5547 "f2 ", "f3 ", "f4 ", "f5 ",
5548 "f6 ", "f7 ", "f8 ", "f9 ",
5549 "f10 ", "f11 ", "f12 ", "esc ",
5550 "~ ", "- ", "= ", "backspace ",
5551 "tab ", "{ ", "} ", "enter ",
5552 ": ", "quote ", "\\ ", "\\ (2) ",
5553 ", ", ". ", "/ ", "space ",
5554 "insert ", "delete ", "home ", "end ",
5555 "page up ", "page down ", "left ", "right ",
5556 "up ", "down ", "num / ", "num * ",
5557 "num - ", "num + ", "num delete ", "num enter ",
5558 "print screen ", "pause ", "abnt c1 ", "yen ",
5559 "kana ", "convert ", "no convert ", "at ",
5560 "circumflex ", ": (2) ", "kanji ", "num = ",
5561 "back quote ", "; ", "command ", "unknown (0) ",
5562 "unknown (1) ", "unknown (2) ", "unknown (3) ", "unknown (4) ",
5563 "unknown (5) ", "unknown (6) ", "unknown (7) ", "left shift ",
5564 "right shift ", "left control ", "right control", "alt ",
5565 "alt gr ", "left win ", "right win ", "menu ",
5566 "scroll lock ", "number lock ", "caps lock ", "MAX"
5567 };
5568
5569
5570 const char *pan_str[4] = { "MONO", " 1/2", " 3/4", "FULL" };
5571 //extern int32_t zcmusic_bufsz;
5572
5573 static char str_a[80],str_b[80],str_s[80],str_m[80],str_l[80],str_r[80],str_p[80],str_ex1[80],str_ex2[80],str_ex3[80],str_ex4[80],
5574 str_leftmod1[80],str_leftmod2[80],str_rightmod1[80],str_rightmod2[80], str_left[80], str_right[80], str_up[80], str_down[80];
5575
5576 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c)
5577 {
5578 //these are here to bypass compiler warnings about unused arguments
5579 c=c;
5580
5581 if(msg==MSG_DRAW)
5582 {
5583 switch(d->w)
5584 {
5585 case 0:
5586 sprintf(str_a,"%03d\n%s",Akey,key_str[Akey]);
5587 sprintf(str_b,"%03d\n%s",Bkey,key_str[Bkey]);
5588 sprintf(str_s,"%03d\n%s",Skey,key_str[Skey]);
5589 sprintf(str_l,"%03d\n%s",Lkey,key_str[Lkey]);
5590 sprintf(str_r,"%03d\n%s",Rkey,key_str[Rkey]);
5591 sprintf(str_p,"%03d\n%s",Pkey,key_str[Pkey]);
5592 sprintf(str_ex1,"%03d\n%s",Exkey1,key_str[Exkey1]);
5593 sprintf(str_ex2,"%03d\n%s",Exkey2,key_str[Exkey2]);
5594 sprintf(str_ex3,"%03d\n%s",Exkey3,key_str[Exkey3]);
5595 sprintf(str_ex4,"%03d\n%s",Exkey4,key_str[Exkey4]);
5596 sprintf(str_up,"%03d\n%s",DUkey,key_str[DUkey]);
5597 sprintf(str_down,"%03d\n%s",DDkey,key_str[DDkey]);
5598 sprintf(str_left,"%03d\n%s",DLkey,key_str[DLkey]);
5599 sprintf(str_right,"%03d\n%s",DRkey,key_str[DRkey]);
5600 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5601 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5602 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5603 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5604 break;
5605
5606 case 1:
5607 sprintf(str_a,"%03d\n%s",Abtn,joybtn_name(Abtn));
5608 sprintf(str_b,"%03d\n%s",Bbtn,joybtn_name(Bbtn));
5609 sprintf(str_s,"%03d\n%s",Sbtn,joybtn_name(Sbtn));
5610 sprintf(str_l,"%03d\n%s",Lbtn,joybtn_name(Lbtn));
5611 sprintf(str_r,"%03d\n%s",Rbtn,joybtn_name(Rbtn));
5612 sprintf(str_m,"%03d\n%s",Mbtn,joybtn_name(Mbtn));
5613 sprintf(str_p,"%03d\n%s",Pbtn,joybtn_name(Pbtn));
5614 sprintf(str_ex1,"%03d\n%s",Exbtn1,joybtn_name(Exbtn1));
5615 sprintf(str_ex2,"%03d\n%s",Exbtn2,joybtn_name(Exbtn2));
5616 sprintf(str_ex3,"%03d\n%s",Exbtn3,joybtn_name(Exbtn3));
5617 sprintf(str_ex4,"%03d\n%s",Exbtn4,joybtn_name(Exbtn4));
5618 sprintf(str_up,"%03d\n%s",DUbtn,joybtn_name(DUbtn));
5619 sprintf(str_down,"%03d\n%s",DDbtn,joybtn_name(DDbtn));
5620 sprintf(str_left,"%03d\n%s",DLbtn,joybtn_name(DLbtn));
5621 sprintf(str_right,"%03d\n%s",DRbtn,joybtn_name(DRbtn));
5622 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5623 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5624 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5625 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5626 break;
5627
5628 case 2:
5629 sprintf(str_a," %3d",midi_volume);
5630 sprintf(str_b," %3d",digi_volume);
5631 sprintf(str_l," %3d",emusic_volume);
5632 sprintf(str_m," %3dKB",zcmusic_bufsz);
5633 sprintf(str_r," %3d",sfx_volume);
5634 strcpy(str_s,pan_str[pan_style]);
5635 sprintf(str_leftmod1,"%3d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5636 sprintf(str_leftmod2,"%3d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5637 sprintf(str_rightmod1,"%3d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5638 sprintf(str_rightmod2,"%3d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5639 break;
5640 }
5641 }
5642
5643 return D_O_K;
5644 }
5645
5646 int32_t set_vol(void *dp3, int32_t d2)
5647 {
5648 switch(((int32_t*)dp3)[0])
5649 {
5650 case 0:
5651 midi_volume = zc_min(d2<<3,255);
5652 break;
5653
5654 case 1:
5655 digi_volume = zc_min(d2<<3,255);
5656 break;
5657
5658 case 2:
5659 emusic_volume = zc_min(d2<<3,255);
5660 break;
5661
5662 case 3:
5663 sfx_volume = zc_min(d2<<3,255);
5664 break;
5665 }
5666
5667 scare_mouse();
5668 // text_mode(vc(11));
5669 textprintf_right_ex(screen,is_large ? lfont_l : font, ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3d",zc_min(d2<<3,255));
5670 unscare_mouse();
5671 return D_O_K;
5672 }
5673
5674 int32_t set_pan(void *dp3, int32_t d2)
5675 {
5676 pan_style = vbound(d2,0,3);
5677 scare_mouse();
5678 // text_mode(vc(11));
5679 textout_right_ex(screen,is_large ? lfont_l : font, pan_str[pan_style],((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5680 unscare_mouse();
5681 return D_O_K;
5682 }
5683
5684 int32_t set_buf(void *dp3, int32_t d2)
5685 {
5686 scare_mouse();
5687 // text_mode(vc(11));
5688 zcmusic_bufsz = d2 + 1;
5689 textprintf_right_ex(screen,is_large ? lfont_l : font, ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3dKB",zcmusic_bufsz);
5690 unscare_mouse();
5691 return D_O_K;
5692 }
5693
5694 static int32_t gamepad_btn_list[] =
5695 {
5696 6,
5697 7,8,9,10,11,12,13,14,15,16,17,
5698 18,19,20,21,22,23,24,25,26,27,28,
5699 29,30,31,32,33,34,35,36,37,38,39,
5700 -1
5701 };
5702
5703 static int32_t gamepad_dirs_list[] =
5704 {
5705 40,41,42,43,
5706 44,45,46,47,
5707 48,49,50,51,
5708 52,53,54,55,
5709 56,
5710 -1
5711 };
5712
5713 static TABPANEL gamepad_tabs[] =
5714 {
5715 // (text)
5716 { (char *)"Buttons", D_SELECTED, gamepad_btn_list, 0, NULL },
5717 { (char *)"Directions", 0, gamepad_dirs_list, 0, NULL },
5718 { NULL, 0, NULL, 0, NULL }
5719 };
5720
5721 static DIALOG gamepad_dlg[] =
5722 {
5723 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5724 { jwin_win_proc, 8, 24, 304, 256, 0, 0, 0, D_EXIT, 0, 0, (void *) "Gamepad Controls", NULL, NULL },
5725 { jwin_tab_proc, 8+4, 24+23,304-8,256-52,vc(0), vc(15), 0, 0, 0, 0, (void *) gamepad_tabs, NULL, (void *)gamepad_dlg },
5726 { d_stringloader, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5727 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5728 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5729 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5730 // 6
5731 { d_dummy_proc, 14, 61, 294, 192, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5732 // 7
5733 { jwin_ctext_proc, 92, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5734 { jwin_ctext_proc, 92, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5735 { jwin_ctext_proc, 92, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5736 { jwin_ctext_proc, 92, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5737 { jwin_ctext_proc, 92, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5738 { jwin_ctext_proc, 237, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5739 { jwin_ctext_proc, 237, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5740 { jwin_ctext_proc, 237, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5741 { jwin_ctext_proc, 237, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5742 { jwin_ctext_proc, 237, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5743 { jwin_ctext_proc, 92, 244-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_m, NULL, NULL },
5744 // 18
5745 { d_jbutton_proc, 22, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Abtn},
5746 { d_jbutton_proc, 22, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bbtn},
5747 { d_jbutton_proc, 22, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Sbtn},
5748 { d_jbutton_proc, 22, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exbtn1},
5749 { d_jbutton_proc, 22, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exbtn3},
5750 { d_jbutton_proc, 167, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lbtn},
5751 { d_jbutton_proc, 167, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rbtn},
5752 { d_jbutton_proc, 167, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pbtn},
5753 { d_jbutton_proc, 167, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exbtn2},
5754 { d_jbutton_proc, 167, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exbtn4},
5755 { d_jbutton_proc, 22, 242-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Menu", NULL, &Mbtn},
5756 // 29
5757 { d_j_clearbutton_proc, 22+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Abtn},
5758 { d_j_clearbutton_proc, 22+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bbtn},
5759 { d_j_clearbutton_proc, 22+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Sbtn},
5760 { d_j_clearbutton_proc, 22+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn1},
5761 { d_j_clearbutton_proc, 22+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn3},
5762 { d_j_clearbutton_proc, 167+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lbtn},
5763 { d_j_clearbutton_proc, 167+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rbtn},
5764 { d_j_clearbutton_proc, 167+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pbtn},
5765 { d_j_clearbutton_proc, 167+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn2},
5766 { d_j_clearbutton_proc, 167+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn4},
5767 { d_j_clearbutton_proc, 22+91, 242-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Mbtn},
5768 // 40
5769 { jwin_frame_proc, 14, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5770 { jwin_frame_proc, 159, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5771 { jwin_text_proc, 30, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5772 { jwin_text_proc, 175, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5773 // 44
5774 { jwin_text_proc, 92, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5775 { jwin_text_proc, 92, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5776 { jwin_text_proc, 237, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5777 { jwin_text_proc, 237, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5778 // 48
5779 { d_jbutton_proc, 22, 82, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUbtn },
5780 { d_jbutton_proc, 22, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDbtn },
5781 { d_jbutton_proc, 167, 82, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLbtn },
5782 { d_jbutton_proc, 167, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRbtn },
5783 // 52
5784 { d_j_clearbutton_proc, 22+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUbtn},
5785 { d_j_clearbutton_proc, 22+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDbtn},
5786 { d_j_clearbutton_proc, 167+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLbtn},
5787 { d_j_clearbutton_proc, 167+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRbtn},
5788 // 56
5789 { jwin_check_proc, 22, 150, 147, 8, vc(14), vc(1), 0, 0, 1, 0, (void *) "Use Analog Stick/DPad", NULL, NULL },
5790 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5791 };
5792
5793 static int32_t keyboard_keys_list[] =
5794 {
5795 6,7,8,9,10,
5796 11,12,13,14,15,16,17,18,19,20,
5797 21,22,23,24,25,26,27,28,29,30,
5798 31,32,33,34,35,36,37,38,39,40,
5799 -1
5800 };
5801
5802 static int32_t keyboard_dirs_list[] =
5803 {
5804 41,42,43,44,
5805 45,46,47,48,
5806 49,50,51,52,
5807 53,54,55,56,
5808 -1
5809 };
5810
5811 static int32_t keyboard_mods_list[] =
5812 {
5813 57,58,59,60,
5814 61,62,63,64,
5815 65,66,67,68,
5816 69,70,71,72,
5817 -1
5818 };
5819
5820 static TABPANEL keyboard_control_tabs[] =
5821 {
5822 // (text)
5823 { (char *)"Keys", D_SELECTED, keyboard_keys_list, 0, NULL },
5824 { (char *)"Directions", 0, keyboard_dirs_list, 0, NULL },
5825 { (char *)"Cheat Mods", 0, keyboard_mods_list, 0, NULL },
5826 { NULL, 0, NULL, 0, NULL }
5827 };
5828
5829 static DIALOG keyboard_control_dlg[] =
5830 {
5831 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5832 { jwin_win_proc, 8, 39, 304, 240, 0, 0, 0, D_EXIT, 0, 0, (void *) "Keyboard Controls", NULL, NULL },
5833 { jwin_tab_proc, 8+4, 39+23,304-8,240-56,vc(0), vc(15), 0, 0, 0, 0, (void *) keyboard_control_tabs, NULL, (void *)keyboard_control_dlg },
5834 { d_stringloader, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5835 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5836 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5837 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5838 // Keys
5839 // 6
5840 { jwin_frame_proc, 14, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5841 { jwin_frame_proc, 158, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5842 { jwin_frame_proc, 14, 181, 292, 67, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5843 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Standard", NULL, NULL },
5844 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Extended", NULL, NULL },
5845 // 11
5846 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5847 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5848 { jwin_text_proc, 92-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5849 { jwin_text_proc, 92-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5850 { jwin_text_proc, 92-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5851 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5852 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5853 { jwin_text_proc, 237-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5854 { jwin_text_proc, 237-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5855 { jwin_text_proc, 237-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5856 // 21
5857 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Akey},
5858 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bkey},
5859 { d_kbutton_proc, 22, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Skey},
5860 { d_kbutton_proc, 22, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exkey1},
5861 { d_kbutton_proc, 22, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exkey3},
5862 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lkey},
5863 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rkey},
5864 { d_kbutton_proc, 167, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pkey},
5865 { d_kbutton_proc, 167, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exkey2},
5866 { d_kbutton_proc, 167, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exkey4},
5867 // 31
5868 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Akey},
5869 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bkey},
5870 { d_k_clearbutton_proc, 22+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Skey},
5871 { d_k_clearbutton_proc, 22+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey1},
5872 { d_k_clearbutton_proc, 22+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey3},
5873 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lkey},
5874 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rkey},
5875 { d_k_clearbutton_proc, 167+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pkey},
5876 { d_k_clearbutton_proc, 167+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey2},
5877 { d_k_clearbutton_proc, 167+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey4},
5878 // Dirs
5879 // 41
5880 { jwin_frame_proc, 14, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5881 { jwin_frame_proc, 159, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5882 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5883 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5884 // 45
5885 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5886 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5887 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5888 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5889 // 49
5890 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUkey},
5891 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDkey},
5892 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLkey},
5893 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRkey},
5894 // 53
5895 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUkey},
5896 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDkey},
5897 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLkey},
5898 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRkey},
5899 // Mods
5900 // 57
5901 { jwin_frame_proc, 14, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5902 { jwin_frame_proc, 158, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5903 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Left", NULL, NULL },
5904 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Right", NULL, NULL },
5905 // 61
5906 { jwin_text_proc, 92-26, 101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod1, NULL, NULL },
5907 { jwin_text_proc, 92-26, 129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod1, NULL, NULL },
5908 { jwin_text_proc, 237-4-22,101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod2, NULL, NULL },
5909 { jwin_text_proc, 237-4-22,129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod2, NULL, NULL },
5910 // 65
5911 { d_kbutton_proc, 22, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[0]},
5912 { d_kbutton_proc, 22, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[2]},
5913 { d_kbutton_proc, 167, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[1]},
5914 { d_kbutton_proc, 167, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[3]},
5915 // 69
5916 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[0]},
5917 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[2]},
5918 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[1]},
5919 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[3]},
5920 // 73
5921 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5922 };
5923
5924 /*
5925 int32_t midi_dp[3] = {0,147,104};
5926 int32_t digi_dp[3] = {1,147,120};
5927 int32_t pan_dp[3] = {0,147,136};
5928 int32_t buf_dp[3] = {0,147,152};
5929 */
5930 int32_t midi_dp[3] = {0,0,0};
5931 int32_t digi_dp[3] = {1,0,0};
5932 int32_t emus_dp[3] = {2,0,0};
5933 int32_t buf_dp[3] = {0,0,0};
5934 int32_t sfx_dp[3] = {3,0,0};
5935 int32_t pan_dp[3] = {0,0,0};
5936
5937 static DIALOG sound_dlg[] =
5938 {
5939 //(dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5940 28 { jwin_win_proc, 0, 0, 320, 178, 0, 0, 0, D_EXIT, 0, 0, (void *) "Sound Settings", NULL, NULL },
5941 28 { d_stringloader, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5942 28 { jwin_button_proc, 58, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5943 28 { jwin_button_proc, 138, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5944 28 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5945 28 { jwin_frame_proc, 10, 28, 300, 112, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
5946 28 { jwin_rtext_proc, 190, 40, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_a, NULL, NULL },
5947 28 { jwin_rtext_proc, 190, 56, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_b, NULL, NULL },
5948 28 { jwin_rtext_proc, 190, 72, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_l, NULL, NULL },
5949 28 { jwin_rtext_proc, 190, 88, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_m, NULL, NULL },
5950 // 10
5951 28 { jwin_rtext_proc, 190, 104, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_r, NULL, NULL },
5952 28 { jwin_rtext_proc, 190, 120, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_s, NULL, NULL },
5953 28 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5954 28 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5955 28 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5956 28 { jwin_slider_proc, 196, 40, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, midi_dp },
5957 28 { jwin_slider_proc, 196, 56, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, digi_dp },
5958 28 { jwin_slider_proc, 196, 72, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, emus_dp },
5959 28 { jwin_slider_proc, 196, 88, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 127, 0, NULL, (void *) set_buf, buf_dp },
5960 28 { jwin_slider_proc, 196, 104, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, sfx_dp },
5961 //20
5962 28 { jwin_slider_proc, 196, 120, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 3, 0, NULL, (void *) set_pan, pan_dp },
5963 28 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5964 28 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5965 28 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5966 28 { jwin_text_proc, 17, 40, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master MIDI Volume", NULL, NULL },
5967 28 { jwin_text_proc, 17, 56, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master Digi Volume", NULL, NULL },
5968 28 { jwin_text_proc, 17, 72, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Volume", NULL, NULL },
5969 28 { jwin_text_proc, 17, 88, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Buffer", NULL, NULL },
5970 28 { jwin_text_proc, 17, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Volume", NULL, NULL },
5971 28 { jwin_text_proc, 17, 120, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Pan", NULL, NULL },
5972 //30
5973 28 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5974 28 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5975 28 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5976 28 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5977 };
5978
5979 char zc_builddate[80];
5980 char zc_aboutstr[80];
5981
5982 static DIALOG about_dlg[] =
5983 {
5984 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5985 { jwin_win_proc, 68, 52, 184, 154, 0, 0, 0, D_EXIT, 0, 0, (void *) "About", NULL, NULL },
5986 { jwin_button_proc, 140, 176, 41, 21, vc(14), 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5987 { jwin_ctext_proc, 160, 84, 0, 8, vc(0), vc(11), 0, 0, 0, 0, zc_aboutstr, NULL, NULL },
5988 { jwin_ctext_proc, 160, 92, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5989 { jwin_ctext_proc, 160, 100, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, zc_builddate, NULL, NULL },
5990 { jwin_text_proc, 88, 124, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Coded by:", NULL, NULL },
5991 { jwin_text_proc, 88, 132, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Phantom Menace", NULL, NULL },
5992 { jwin_text_proc, 88, 144, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Produced by:", NULL, NULL },
5993 { jwin_text_proc, 88, 152, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Armageddon Games", NULL, NULL },
5994 { jwin_frame_proc, 80, 117, 160, 50, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5995 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5996 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5997 };
5998
5999
6000 static DIALOG quest_dlg[] =
6001 {
6002 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6003 { jwin_win_proc, 68, 25, 184, 190, 0, 0, 0, D_EXIT, 0, 0, (void *) "Quest Info", NULL, NULL },
6004 { jwin_edit_proc, 84, 54, 152, 16, 0, 0, 0, D_READONLY, 100, 0, NULL, NULL, NULL },
6005 { jwin_text_proc, 89, 84, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
6006 { jwin_text_proc, 152, 84, 24, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
6007 { jwin_text_proc, 89, 94, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Version:", NULL, NULL },
6008 { jwin_text_proc, 160, 94, 64, 8, vc(7), vc(11), 0, 0, 0, 0, header_version_nul_term, NULL, NULL },
6009 { jwin_text_proc, 89, 104, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "ZQ Version:", NULL, NULL },
6010 { jwin_text_proc, 184, 104, 64, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
6011 { jwin_text_proc, 84, 126, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Title:", NULL, NULL },
6012 { jwin_textbox_proc, 84, 136, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.title, NULL, NULL },
6013 { jwin_text_proc, 84, 168, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Author:", NULL, NULL },
6014 { jwin_textbox_proc, 84, 178, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.author, NULL, NULL },
6015 { jwin_frame_proc, 84, 79, 152, 38, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
6016 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6017 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6018 };
6019
6020 static DIALOG triforce_dlg[] =
6021 {
6022 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
6023 { jwin_win_proc, 72, 64, 177, 105, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Triforce Pieces", NULL, NULL },
6024 // 1
6025 { jwin_check_proc, 129, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "1", NULL, NULL },
6026 { jwin_check_proc, 129, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "2", NULL, NULL },
6027 { jwin_check_proc, 129, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "3", NULL, NULL },
6028 { jwin_check_proc, 129, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "4", NULL, NULL },
6029 { jwin_check_proc, 172, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "5", NULL, NULL },
6030 { jwin_check_proc, 172, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "6", NULL, NULL },
6031 { jwin_check_proc, 172, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "7", NULL, NULL },
6032 { jwin_check_proc, 172, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "8", NULL, NULL },
6033 // 9
6034 { jwin_button_proc, 90, 144, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6035 { jwin_button_proc, 170, 144, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6036 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6037 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6038 };
6039
6040 /*static DIALOG equip_dlg[] =
6041 {
6042 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
6043 { jwin_win_proc, 16, 18, 289, 215, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Equipment", NULL, NULL },
6044 // 1
6045 { jwin_button_proc, 90, 206, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6046 { jwin_button_proc, 170, 206, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6047 // 3
6048 { jwin_frame_proc, 25, 45, 77, 50, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6049 { jwin_text_proc, 29, 42, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Sword", NULL, NULL },
6050 { jwin_check_proc, 33, 52, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Wooden", NULL, NULL },
6051 { jwin_check_proc, 33, 62, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "White", NULL, NULL },
6052 { jwin_check_proc, 33, 72, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Magic", NULL, NULL },
6053 { jwin_check_proc, 33, 82, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Master", NULL, NULL },
6054 // 9
6055 { jwin_frame_proc, 25, 99, 77, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6056 { jwin_text_proc, 29, 96, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Shield", NULL, NULL },
6057 { jwin_check_proc, 33, 106, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Small", NULL, NULL },
6058 { jwin_check_proc, 33, 116, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Magic", NULL, NULL },
6059 { jwin_check_proc, 33, 126, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Mirror", NULL, NULL },
6060 // 14
6061 { jwin_frame_proc, 25, 143, 61, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6062 { jwin_text_proc, 29, 140, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Ring", NULL, NULL },
6063 { jwin_check_proc, 33, 150, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Blue", NULL, NULL },
6064 { jwin_check_proc, 33, 160, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Red", NULL, NULL },
6065 { jwin_check_proc, 33, 170, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Gold", NULL, NULL },
6066 // 19
6067 { jwin_frame_proc, 110, 45, 85, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6068 { jwin_text_proc, 114, 42, 64, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Bracelet", NULL, NULL },
6069 { jwin_check_proc, 118, 52, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 1", NULL, NULL },
6070 { jwin_check_proc, 118, 62, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 2", NULL, NULL },
6071 // 23
6072 { jwin_frame_proc, 110, 79, 85, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6073 { jwin_text_proc, 114, 76, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Amulet", NULL, NULL },
6074 { jwin_check_proc, 118, 86, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 1", NULL, NULL },
6075 { jwin_check_proc, 118, 96, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 2", NULL, NULL },
6076 // 27
6077 { jwin_frame_proc, 110, 113, 69, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6078 { jwin_text_proc, 114, 110, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Wallet", NULL, NULL },
6079 { jwin_check_proc, 118, 120, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Small", NULL, NULL },
6080 { jwin_check_proc, 118, 130, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Large", NULL, NULL },
6081 // 31
6082 { jwin_frame_proc, 110, 147, 69, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6083 { jwin_text_proc, 114, 144, 24, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Bow", NULL, NULL },
6084 { jwin_check_proc, 118, 154, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Small", NULL, NULL },
6085 { jwin_check_proc, 118, 164, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Large", NULL, NULL },
6086 // 35
6087 { jwin_frame_proc, 203, 45, 93, 70, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6088 { jwin_text_proc, 207, 42, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Other", NULL, NULL },
6089 { jwin_check_proc, 211, 52, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Raft", NULL, NULL },
6090 { jwin_check_proc, 211, 62, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Ladder", NULL, NULL },
6091 { jwin_check_proc, 211, 72, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Book", NULL, NULL },
6092 { jwin_check_proc, 211, 82, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Magic Key", NULL, NULL },
6093 { jwin_check_proc, 211, 92, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Flippers", NULL, NULL },
6094 { jwin_check_proc, 211, 102, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Boots", NULL, NULL },
6095 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6096 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6097 };
6098
6099 static DIALOG items_dlg[] =
6100 {
6101 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
6102 { jwin_win_proc, 16, 18, 289, 215, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Items", NULL, NULL },
6103 //1
6104 { jwin_button_proc, 90, 206, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6105 { jwin_button_proc, 170, 206, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6106 // 3
6107 { jwin_frame_proc, 27, 45, 77, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6108 { jwin_text_proc, 31, 42, 64, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Boomerang", NULL, NULL },
6109 { jwin_check_proc, 35, 52, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Wooden", NULL, NULL },
6110 { jwin_check_proc, 35, 62, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Magic", NULL, NULL },
6111 { jwin_check_proc, 35, 72, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Fire", NULL, NULL },
6112 // 8
6113 { jwin_frame_proc, 27, 89, 77, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6114 { jwin_text_proc, 31, 86, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Arrow", NULL, NULL },
6115 { jwin_check_proc, 35, 96, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Wooden", NULL, NULL },
6116 { jwin_check_proc, 35, 106, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Silver", NULL, NULL },
6117 { jwin_check_proc, 35, 116, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Golden", NULL, NULL },
6118 // 13
6119 { jwin_frame_proc, 27, 133, 63, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6120 { jwin_text_proc, 31, 130, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Potion", NULL, NULL },
6121 { jwin_radio_proc, 35, 140, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "None", NULL, NULL },
6122 { jwin_radio_proc, 35, 150, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Blue", NULL, NULL },
6123 { jwin_radio_proc, 35, 160, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Red", NULL, NULL },
6124 // 18
6125 { jwin_frame_proc, 114, 45, 93, 20, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6126 { jwin_text_proc, 118, 42, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Whistle", NULL, NULL },
6127 { jwin_check_proc, 122, 52, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Recorder", NULL, NULL },
6128 // 21
6129 { jwin_frame_proc, 114, 69, 86, 20, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6130 { jwin_text_proc, 118, 66, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Hammer", NULL, NULL },
6131 { jwin_check_proc, 122, 76, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 1", NULL, NULL },
6132 // 24
6133 { jwin_frame_proc, 114, 93, 69, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6134 { jwin_text_proc, 118, 90, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Hookshot", NULL, NULL },
6135 { jwin_check_proc, 122, 100, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Short", NULL, NULL },
6136 { jwin_check_proc, 122, 110, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Long", NULL, NULL },
6137 // 28
6138 { jwin_frame_proc, 114, 127, 60, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6139 { jwin_text_proc, 118, 124, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Candle", NULL, NULL },
6140 { jwin_check_proc, 122, 134, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Blue", NULL, NULL },
6141 { jwin_check_proc, 122, 144, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Red", NULL, NULL },
6142 // 32
6143 { jwin_frame_proc, 217, 45, 77, 138, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6144 { jwin_text_proc, 221, 42, 80, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Other", NULL, NULL },
6145 { jwin_check_proc, 225, 52, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Bait", NULL, NULL },
6146 { jwin_check_proc, 225, 62, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Letter", NULL, NULL },
6147 { jwin_check_proc, 225, 72, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Wand", NULL, NULL },
6148 { jwin_check_proc, 225, 82, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Lens", NULL, NULL },
6149 { jwin_check_proc, 225, 92, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Din's Fire", NULL, NULL },
6150 { jwin_check_proc, 225, 102, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Farore's Wind", NULL, NULL },
6151 { jwin_check_proc, 225, 112, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Nayru's Love", NULL, NULL },
6152 { jwin_text_proc, 225, 132, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Bombs:", NULL, NULL },
6153 { jwin_edit_proc, 229, 142, 40, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
6154 { jwin_text_proc, 225, 162, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "S-Bombs:", NULL, NULL },
6155 { jwin_edit_proc, 229, 162, 40, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
6156 { jwin_check_proc, 225, 122, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Cane of Byrna", NULL, NULL },
6157 //45
6158 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6159 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6160 };*/
6161
6162
6163
6164 bool zc_getname(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
6165 {
6166 go();
6167 int32_t ret=0;
6168 ret = zc_getname_nogo(prompt,ext,list,def,usefilename);
6169 comeback();
6170 return ret != 0;
6171 }
6172
6173
6174 bool zc_getname_nogo(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
6175 {
6176 if(def!=modulepath)
6177 strcpy(modulepath,def);
6178
6179 if(!usefilename)
6180 {
6181 int32_t i=(int32_t)strlen(modulepath);
6182
6183 while(i>=0 && modulepath[i]!='\\' && modulepath[i]!='/')
6184 modulepath[i--]=0;
6185 }
6186
6187 // int32_t ret = file_select_ex(prompt,modulepath,ext,255,-1,-1);
6188 int32_t ret=0;
6189 int32_t sel=0;
6190
6191 if(list==NULL)
6192 {
6193 ret = jwin_file_select_ex(prompt,modulepath,ext,2048,-1,-1,lfont);
6194 }
6195 else
6196 {
6197 ret = jwin_file_browse_ex(prompt, modulepath, list, &sel, 2048, -1, -1, lfont);
6198 }
6199
6200 return ret!=0;
6201 }
6202
6203 //The Dialogue that loads a ZMOD Module File
6204 int32_t zc_load_zmod_module_file()
6205 {
6206 if ( Playing )
6207 {
6208 jwin_alert("Error","Cannot change module while playing a quest!",NULL,NULL,"O&K",NULL,'k',0,lfont);
6209 return -1;
6210 }
6211 if(!zc_getname("Load Module (.zmod)","zmod",NULL,modulepath,false))
6212 return D_CLOSE;
6213
6214 FILE *tempmodule = fopen(modulepath,"r");
6215
6216 if(tempmodule == NULL)
6217 {
6218 jwin_alert("Error","Cannot open specified file!",NULL,NULL,"O&K",NULL,'k',0,lfont);
6219 return -1;
6220 }
6221
6222
6223 //Set the module path:
6224 memset(moduledata.module_name, 0, sizeof(moduledata.module_name));
6225 strcpy(moduledata.module_name, modulepath);
6226 al_trace("New Module Path is: %s \n", moduledata.module_name);
6227 zc_set_config("ZCMODULE","current_module",moduledata.module_name);
6228 zcm.init(true); //Load the module values.
6229 moduledata.refresh_title_screen = 1;
6230 // refresh_select_screen = 1;
6231 build_biic_list();
6232 return D_O_K;
6233 }
6234
6235 static DIALOG module_info_dlg[] =
6236 {
6237 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
6238
6239
6240 { jwin_win_proc, 0, 0, 200, 200, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "About Current Module", NULL, NULL },
6241 //1
6242 { jwin_text_proc, 10, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Module:", NULL, NULL },
6243 //2
6244 { jwin_text_proc, 50, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6245 { jwin_text_proc, 10, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Author:", NULL, NULL },
6246 //4
6247 { jwin_text_proc, 50, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6248 { jwin_text_proc, 10, 40, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6249 { jwin_text_proc, 10, 50, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Information:", NULL, NULL },
6250 //7
6251
6252 { jwin_text_proc, 10, 60, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6253 { jwin_text_proc, 10, 70, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6254 { jwin_text_proc, 10, 80, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6255 { jwin_text_proc, 10, 90, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6256 { jwin_text_proc, 10, 100, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6257 { jwin_text_proc, 10, 120, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6258 { jwin_text_proc, 10, 130, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6259 { jwin_text_proc, 10, 140, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6260 { jwin_text_proc, 10, 150, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6261
6262 { jwin_button_proc, 40, 160, 50, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6263 { jwin_button_proc, 200-40-50, 160, 50, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6264 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6265 };
6266
6267 void about_zcplayer_module(const char *prompt,int32_t initialval)
6268 {
6269
6270 module_info_dlg[0].dp2 = lfont;
6271 if ( moduledata.moduletitle[0] != 0 )
6272 module_info_dlg[2].dp = (char*)moduledata.moduletitle;
6273
6274 if ( moduledata.moduleauthor[0] != 0 )
6275 module_info_dlg[4].dp = (char*)moduledata.moduleauthor;
6276
6277 if ( moduledata.moduleinfo0[0] != 0 )
6278 module_info_dlg[7].dp = (char*)moduledata.moduleinfo0;
6279 if ( moduledata.moduleinfo1[0] != 0 )
6280 module_info_dlg[8].dp = (char*)moduledata.moduleinfo1;
6281 if ( moduledata.moduleinfo2[0] != 0 )
6282 module_info_dlg[9].dp = (char*)moduledata.moduleinfo2;
6283 if ( moduledata.moduleinfo3[0] != 0 )
6284 module_info_dlg[10].dp = (char*)moduledata.moduleinfo3;
6285 if ( moduledata.moduleinfo4[0] != 0 )
6286 module_info_dlg[11].dp = (char*)moduledata.moduleinfo4;
6287
6288 char module_date[255];
6289 memset(module_date, 0, sizeof(module_date));
6290 sprintf(module_date,"Build Date: %s %s, %d at @ %d:%d %s", dayextension(moduledata.modday).c_str(),
6291 (char*)months[moduledata.modmonth], moduledata.modyear, moduledata.modhour, moduledata.modminute, moduledata.moduletimezone);
6292
6293
6294
6295 char module_vers[255];
6296 memset(module_vers, 0, sizeof(module_vers));
6297 sprintf(module_vers, "Version: %d.%d.%d.%d", moduledata.modver_1, moduledata.modver_2, moduledata.modver_3, moduledata.modver_4);
6298
6299
6300 //sprintf(tilecount,"%d",1);
6301
6302 char module_build[255];
6303 memset(module_build, 0, sizeof(module_build));
6304 if ( moduledata.modbeta )
6305 sprintf(module_build,"Module Build: %d, %s: %d", moduledata.modbuild, (moduledata.modbeta<0) ? "Alpha" : "Beta", moduledata.modbeta );
6306 else
6307 sprintf(module_build,"Module Build: %d", moduledata.modbuild);
6308
6309 module_info_dlg[12].dp = (char*)module_date;
6310 module_info_dlg[13].dp = (char*)module_vers;
6311 module_info_dlg[14].dp = (char*)module_build;
6312
6313 if(is_large)
6314 large_dialog(module_info_dlg);
6315
6316 int32_t ret = zc_popup_dialog(module_info_dlg,-1);
6317 jwin_center_dialog(module_info_dlg);
6318
6319
6320 }
6321
6322 int32_t onAbout_ZCP_Module()
6323 {
6324 about_zcplayer_module("About Module (.zmod)", 0);
6325 return D_O_K;
6326 }
6327
6328 //New Modules Menu for 2.55+
6329 static MENU zcmodule_menu[] =
6330 {
6331 { (char *)"&Load Module...", zc_load_zmod_module_file, NULL, 0, NULL },
6332 { (char *)"&About Module", onAbout_ZCP_Module, NULL, 0, NULL },
6333
6334 { NULL, NULL, NULL, 0, NULL }
6335 };
6336
6337 int32_t onToggleRecordingNewSaves()
6338 {
6339 if (zc_get_config("zeldadx", "replay_new_saves", false))
6340 {
6341 zc_set_config("zeldadx", "replay_new_saves", false);
6342 }
6343 else
6344 {
6345 zc_set_config("zeldadx", "replay_new_saves", true);
6346 jwin_alert("Recording", "Newly created saves will be recorded and written to a replay file.",
6347 NULL,NULL,"OK",NULL,13,27,lfont);
6348 }
6349 return D_O_K;
6350 }
6351
6352 int32_t onToggleSnapshotAllFrames()
6353 {
6354 replay_set_snapshot_all_frames(!replay_is_snapshot_all_frames());
6355 return D_O_K;
6356 }
6357
6358 int32_t onStopReplayOrRecord()
6359 {
6360 if (replay_is_replaying())
6361 {
6362 replay_quit();
6363 }
6364 else if (replay_get_mode() == ReplayMode::Record)
6365 {
6366 if (!replay_get_meta_bool("test_mode"))
6367 {
6368 jwin_alert("Recording", "You cannot stop recording a save file.",
6369 NULL,NULL,"OK",NULL,13,27,lfont);
6370 return D_CLOSE;
6371 }
6372
6373 if (jwin_alert("Stop Recording",
6374 "Save replay to disk and stop recording?",
6375 "This will stop the recording.",
6376 NULL,
6377 "Yes","No",13,27,lfont) != 1)
6378 return D_CLOSE;
6379
6380 replay_save();
6381 replay_stop();
6382 }
6383 return D_O_K;
6384 }
6385
6386 static int32_t handle_on_load_replay(ReplayMode mode)
6387 {
6388 if (Playing)
6389 {
6390 if (jwin_alert("Replay - Warning!",
6391 "Loading a replay will exit the current game.",
6392 "All unsaved progress will be lost.",
6393 "Do you wish to continue?",
6394 "Yes","No",13,27,lfont) != 1)
6395 return D_CLOSE;
6396 }
6397
6398 std::string mode_string = replay_mode_to_string(mode);
6399 mode_string[0] = std::toupper(mode_string[0]);
6400
6401 std::string line_1 = "Select a replay file to play back.";
6402 std::string line_2 = "You won't be able to save, and it won't effect existing saves.";
6403 std::string line_3 = "You can stop the replay and take over manually any time.";
6404 if (mode == ReplayMode::Update)
6405 {
6406 line_1 = "Select a replay file to update.";
6407 line_2 = "WARNING: be sure to back up the zplay file";
6408 line_3 = "and verify that the updated replay works as expected!";
6409 }
6410
6411 if (jwin_alert(mode_string.c_str(),
6412 line_1.c_str(),
6413 line_2.c_str(),
6414 line_3.c_str(),
6415 "OK","Nevermind",13,27,lfont) == 1)
6416 {
6417 char replay_path[2048];
6418 strcpy(replay_path, "replays/");
6419 if (jwin_file_select_ex(
6420 fmt::format("Load Replay (.{})", REPLAY_EXTENSION).c_str(),
6421 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, lfont) == 0)
6422 return D_CLOSE;
6423
6424 replay_quit();
6425 load_replay_file_deferred(mode, replay_path);
6426 Quit = qRESET;
6427 return D_CLOSE;
6428 }
6429 return D_O_K;
6430 }
6431
6432 int32_t onLoadReplay()
6433 {
6434 return handle_on_load_replay(ReplayMode::Replay);
6435 }
6436
6437 int32_t onLoadReplayAssert()
6438 {
6439 return handle_on_load_replay(ReplayMode::Assert);
6440 }
6441
6442 int32_t onLoadReplayUpdate()
6443 {
6444 return handle_on_load_replay(ReplayMode::Update);
6445 }
6446
6447 int32_t onSaveReplay()
6448 {
6449 if (replay_get_mode() == ReplayMode::Record)
6450 {
6451 if (!replay_get_meta_bool("test_mode"))
6452 {
6453 if (jwin_alert("Save Replay",
6454 "This will save a copy of the replay up to this point.",
6455 "The official replay file will be untouched.",
6456 "Do you wish to continue?",
6457 "Yes","No",13,27,lfont) != 1)
6458 return D_CLOSE;
6459
6460 char replay_path[2048];
6461 strcpy(replay_path, replay_get_replay_path().string().c_str());
6462 if (jwin_file_select_ex(
6463 fmt::format("Save Replay (.{})", REPLAY_EXTENSION).c_str(),
6464 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, lfont) == 0)
6465 return D_CLOSE;
6466
6467 if (fileexists(replay_path))
6468 {
6469 jwin_alert("Save Replay", "You cannot overwrite an existing file.",
6470 NULL,NULL,"OK",NULL,13,27,lfont);
6471 return D_CLOSE;
6472 }
6473
6474 replay_save(replay_path);
6475 }
6476 else
6477 {
6478 replay_save();
6479 }
6480 }
6481 return D_O_K;
6482 }
6483
6484 static MENU replay_menu[] =
6485 {
6486 { (char *)"Record new saves", onToggleRecordingNewSaves, NULL, 0, NULL },
6487 { (char *)"Stop replay", onStopReplayOrRecord, NULL, 0, NULL },
6488 { (char *)"Load replay", onLoadReplay, NULL, 0, NULL },
6489 { (char *)"Load replay (assert)", onLoadReplayAssert, NULL, 0, NULL },
6490 { (char *)"Load replay (update)", onLoadReplayUpdate, NULL, 0, NULL },
6491 { (char *)"Save replay", onSaveReplay, NULL, 0, NULL },
6492 { (char *)"Enable snapshot all frames", onToggleSnapshotAllFrames,NULL, 0, NULL },
6493
6494 { NULL, NULL, NULL, 0, NULL }
6495 };
6496
6497 static DIALOG credits_dlg[] =
6498 {
6499 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6500 { jwin_win_proc, 40, 38, 241, 173, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Zelda Classic Credits", NULL, NULL },
6501 { jwin_frame_proc, 47, 65, 227, 115, vc(15), vc(1), 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
6502 { d_bitmap_proc, 49, 67, 222, 110, vc(15), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
6503 { jwin_button_proc, 140, 184, 41, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6504 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6505 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6506 };
6507
6508 28 static ListData dmap_list(dmaplist, &font);
6509
6510 static DIALOG goto_dlg[] =
6511 {
6512 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6513 { jwin_win_proc, 48, 25, 205, 100, 0, 0, 0, D_EXIT, 0, 0, (void *) "Goto Location", NULL, NULL },
6514 { jwin_button_proc, 90, 176-78, 61, 21, vc(14), 0, 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6515 { jwin_button_proc, 170, 176-78, 61, 21, vc(14), 0, 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6516 { jwin_text_proc, 55, 129-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
6517 { jwin_droplist_proc, 88, 126-75, 160, 16, 0, 0, 0, 0, 0, 0, (void *) &dmap_list, NULL, NULL },
6518 { jwin_text_proc, 55, 149-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Screen:", NULL, NULL },
6519 { jwin_edit_proc, 132, 146-75, 91, 16, 0, 0, 0, 0, 2, 0, NULL, NULL, NULL },
6520 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6521 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6522 };
6523
6524 int32_t onGoTo()
6525 {
6526 bool music = false;
6527 music = music;
6528 sprintf(cheat_goto_screen_str,"%X",cheat_goto_screen);
6529
6530 goto_dlg[0].dp2=lfont;
6531 goto_dlg[4].d2=cheat_goto_dmap;
6532 goto_dlg[6].dp=cheat_goto_screen_str;
6533
6534 clear_keybuf();
6535
6536 if(is_large)
6537 large_dialog(goto_dlg);
6538
6539 if(zc_popup_dialog(goto_dlg,4)==1)
6540 {
6541 // dmap, screen
6542 cheats_enqueue(Cheat::GoTo, goto_dlg[4].d2, zc_min(zc_xtoi(cheat_goto_screen_str),0x7F));
6543 };
6544
6545 return D_O_K;
6546 }
6547
6548 int32_t onGoToComplete()
6549 {
6550 if(!Playing)
6551 {
6552 return D_O_K;
6553 }
6554
6555 system_pal();
6556 music_pause();
6557 pause_all_sfx();
6558 show_mouse(screen);
6559 onGoTo();
6560 eat_buttons();
6561
6562 zc_readrawkey(KEY_ESC);
6563
6564 show_mouse(NULL);
6565 game_pal();
6566 music_resume();
6567 resume_all_sfx();
6568 return D_O_K;
6569 }
6570
6571 int32_t onCredits()
6572 {
6573 go();
6574
6575 BITMAP *win = create_bitmap_ex(8,222,110);
6576
6577 if(!win)
6578 return D_O_K;
6579
6580 int32_t c=0;
6581 int32_t l=0;
6582 int32_t ol=-1;
6583 RLE_SPRITE *rle = (RLE_SPRITE*)(datafile[RLE_CREDITS].dat);
6584 RGB *pal = (RGB*)(datafile[PAL_CREDITS].dat);
6585 PALETTE tmppal;
6586
6587 rti_gui.transparency_index = 1;
6588
6589 clear_to_color(win, rti_gui.transparency_index);
6590 draw_rle_sprite(win,rle,0,0);
6591 credits_dlg[0].dp2=lfont;
6592 credits_dlg[1].fg = jwin_pal[jcDISABLED_FG];
6593 credits_dlg[2].dp = win;
6594
6595 set_palette_range(black_palette,0,127,false);
6596
6597 DIALOG_PLAYER *p = init_dialog(credits_dlg,3);
6598
6599 BITMAP* old_screen = screen;
6600 BITMAP* gui_bmp = zc_get_gui_bmp();
6601 ASSERT(gui_bmp);
6602 clear_to_color(gui_bmp, rti_gui.transparency_index);
6603 screen = gui_bmp;
6604
6605 while(update_dialog(p))
6606 {
6607 throttleFPS();
6608 ++c;
6609 l = zc_max((c>>1)-30,0);
6610
6611 if(l > rle->h)
6612 l = c = 0;
6613
6614 if(l > rle->h - 112)
6615 l = rle->h - 112;
6616
6617 clear_bitmap(win);
6618 draw_rle_sprite(win,rle,0,0-l);
6619
6620 if(c<=64)
6621 fade_interpolate(black_palette,pal,tmppal,c,0,127);
6622
6623 set_palette_range(tmppal,0,127,false);
6624
6625 if(l!=ol)
6626 {
6627 scare_mouse();
6628 d_bitmap_proc(MSG_DRAW,credits_dlg+2,0);
6629 unscare_mouse();
6630 SCRFIX();
6631 ol=l;
6632 }
6633
6634 update_hw_screen();
6635 }
6636
6637 screen = old_screen;
6638 system_pal();
6639
6640 shutdown_dialog(p);
6641 destroy_bitmap(win);
6642 //comeback();
6643
6644 rti_gui.transparency_index = 0;
6645
6646 return D_O_K;
6647 }
6648
6649 const char *midilist(int32_t index, int32_t *list_size)
6650 {
6651 if(index<0)
6652 {
6653 *list_size=0;
6654
6655 for(int32_t i=0; i<MAXMIDIS; i++)
6656 if(tunes[i].data)
6657 ++(*list_size);
6658
6659 return NULL;
6660 }
6661
6662 int32_t i=0,m=0;
6663
6664 while(m<=index && i<=MAXMIDIS)
6665 {
6666 if(tunes[i].data)
6667 ++m;
6668
6669 ++i;
6670 }
6671
6672 --i;
6673
6674 if(i==MAXMIDIS && m<index)
6675 return "(null)";
6676
6677 return tunes[i].title;
6678 }
6679
6680 /* ------- MIDI info stuff -------- */
6681
6682 char *text;
6683 midi_info *zmi;
6684 bool dialog_running;
6685 bool listening;
6686
6687 void get_info(int32_t index);
6688
6689 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c)
6690 {
6691 int32_t d2 = d->d2;
6692 int32_t ret = jwin_droplist_proc(msg,d,c);
6693
6694 if(d2!=d->d2)
6695 {
6696 get_info(d->d2);
6697 }
6698
6699 return ret;
6700 }
6701
6702 int32_t d_listen_proc(int32_t msg,DIALOG *d,int32_t c)
6703 {
6704 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6705
6706 int32_t ret = jwin_button_proc(msg,d,c);
6707
6708 if(ret == D_CLOSE)
6709 {
6710 // get current midi index
6711 int32_t index = (d+(d->d1))->d2;
6712 int32_t i=0, m=0;
6713
6714 while(m<=index && i<=MAXMIDIS)
6715 {
6716 if(tunes[i].data)
6717 ++m;
6718
6719 ++i;
6720 }
6721
6722 --i;
6723 jukebox(i);
6724 listening = true;
6725 ret = D_O_K;
6726 }
6727
6728 return ret;
6729 }
6730
6731 int32_t d_savemidi_proc(int32_t msg,DIALOG *d,int32_t c)
6732 {
6733 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6734
6735 int32_t ret = jwin_button_proc(msg,d,c);
6736
6737 if(ret == D_CLOSE)
6738 {
6739 // get current midi index
6740 int32_t index = (d+(d->d1))->d2;
6741 int32_t i=0, m=0;
6742
6743 while(m<=index && i<=MAXMIDIS)
6744 {
6745 if(tunes[i].data)
6746 ++m;
6747
6748 ++i;
6749 }
6750
6751 --i;
6752
6753 // get file name
6754
6755 int32_t sel=0;
6756 //struct ffblk f;
6757 char title[40] = "Save MIDI: ";
6758 char fname[2048];
6759 memset(fname,0,2048);
6760 static EXT_LIST list[] =
6761 {
6762 { (char *)"MIDI files (*.mid)", (char *)"mid" },
6763 { (char *)"HTML files (*.html, *.html)", (char *)"htm html" },
6764 { NULL, NULL }
6765 };
6766
6767 strcpy(title+11, tunes[i].title);
6768 title[39] = '\0';
6769
6770 if(jwin_file_browse_ex(title, fname, list, &sel, 2048, -1, -1, lfont)==0)
6771 goto done;
6772
6773 if(exists(fname))
6774 {
6775 if(jwin_alert(title, fname, "already exists.", "Overwrite it?", "&Yes","&No",'y','n',lfont)==2)
6776 goto done;
6777 }
6778
6779 // save midi i
6780
6781 if(save_midi(fname, (MIDI*)tunes[i].data) != 0)
6782 jwin_alert(title, "Error saving MIDI to", fname, NULL, "Darn", NULL,13,27,lfont);
6783
6784 done:
6785 chop_path(fname);
6786 ret = D_REDRAW;
6787 }
6788
6789 return ret;
6790 }
6791
6792 28 static ListData midi_list(midilist, &font);
6793
6794 static DIALOG midi_dlg[] =
6795 {
6796 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6797 { jwin_win_proc, 8, 28, 304, 184, 0, 0, 0, D_EXIT, 0, 0, (void *) "MIDI Info", NULL, NULL },
6798 { jwin_text_proc, 32, 60, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Tune:", NULL, NULL },
6799 { d_midilist_proc, 80, 56, 192, 16, 0, 0, 0, 0, 0, 0, (void *) &midi_list, NULL, NULL },
6800 { jwin_textbox_proc, 15, 80, 290, 96, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6801 { d_listen_proc, 24, 183, 72, 21, 0, 0, 'l', D_EXIT, -2, 0, (void *) "&Listen", NULL, NULL },
6802 { d_savemidi_proc, 108, 183, 72, 21, 0, 0, 's', D_EXIT, -3, 0, (void *) "&Save", NULL, NULL },
6803 { jwin_button_proc, 236, 183, 61, 21, 0, 0, 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6804 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6805 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6806 };
6807
6808 void get_info(int32_t index)
6809 {
6810 int32_t i=0, m=0;
6811
6812 while(m<=index && i<=MAXMIDIS)
6813 {
6814 if(tunes[i].data)
6815 ++m;
6816
6817 ++i;
6818 }
6819
6820 --i;
6821
6822 if(i==MAXMIDIS && m<index)
6823 strcpy(text,"(null)");
6824 else
6825 {
6826 get_midi_info((MIDI*)tunes[i].data,zmi);
6827 get_midi_text((MIDI*)tunes[i].data,zmi,text);
6828 }
6829
6830 midi_dlg[0].dp2=lfont;
6831 midi_dlg[3].dp = text;
6832 midi_dlg[3].d1 = midi_dlg[3].d2 = 0;
6833 midi_dlg[5].flags = (tunes[i].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6834
6835 if(dialog_running)
6836 {
6837 scare_mouse();
6838 jwin_textbox_proc(MSG_DRAW,midi_dlg+3,0);
6839 d_savemidi_proc(MSG_DRAW,midi_dlg+5,0);
6840 unscare_mouse();
6841 }
6842 }
6843
6844 int32_t onMIDICredits()
6845 {
6846 text = (char*)malloc(4096);
6847 zmi = (midi_info*)malloc(sizeof(midi_info));
6848
6849 if(!text || !zmi)
6850 {
6851 jwin_alert(NULL,"Not enough memory",NULL,NULL,"OK",NULL,13,27,lfont);
6852 return D_O_K;
6853 }
6854
6855 bool do_pause_midi = midi_pos >= 0 && currmidi;
6856 auto restore_midi = currmidi;
6857 if(do_pause_midi)
6858 {
6859 paused_midi_pos = midi_pos;
6860 stop_midi();
6861 midi_paused=true;
6862 midi_suspended = midissuspHALTED;
6863 }
6864
6865 midi_dlg[0].dp2=lfont;
6866 midi_dlg[2].d1 = 0;
6867 midi_dlg[2].d2 = 0;
6868 midi_dlg[4].flags = D_EXIT;
6869 midi_dlg[5].flags = (tunes[midi_dlg[2].d1].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6870
6871 listening = false;
6872 dialog_running=false;
6873 get_info(0);
6874
6875 dialog_running=true;
6876
6877 if(is_large)
6878 large_dialog(midi_dlg);
6879
6880 zc_popup_dialog(midi_dlg,0);
6881 dialog_running=false;
6882
6883 if(listening)
6884 music_stop();
6885
6886 if(do_pause_midi)
6887 {
6888 midi_suspended = midissuspRESUME;
6889 currmidi = restore_midi;
6890 midi_pos = paused_midi_pos;
6891 }
6892
6893 if(text) free(text);
6894 if(zmi) free(zmi);
6895 return D_O_K;
6896 }
6897
6898 int32_t onAbout()
6899 {
6900 char buf1[80]={0};
6901 std::ostringstream oss;
6902 sprintf(buf1,"%s (%s), Version: %s", ZC_PLAYER_NAME,PROJECT_NAME,ZC_PLAYER_V);
6903 oss << buf1 << '\n';
6904 sprintf(buf1, "%s, Build %d", ALPHA_VER_STR, VERSION_BUILD);
6905 oss << buf1 << '\n';
6906 sprintf(buf1,"Build Date: %s %s, %d at @ %s %s", dayextension(BUILDTM_DAY).c_str(), (char*)months[BUILDTM_MONTH], BUILDTM_YEAR, __TIME__, __TIMEZONE__);
6907 oss << buf1 << '\n';
6908 sprintf(buf1, "Built By: %s", DEV_SIGNOFF);
6909 oss << buf1 << '\n';
6910 sprintf(buf1, "Tag: %s", getReleaseTag());
6911 oss << buf1 << '\n';
6912
6913 InfoDialog("About ZC", oss.str()).show();
6914 return D_O_K;
6915 }
6916
6917 int32_t onQuest()
6918 {
6919 char fname[100];
6920 strcpy(fname, get_filename(qstpath));
6921 quest_dlg[0].dp2=lfont;
6922 quest_dlg[1].dp = fname;
6923
6924 if(QHeader.quest_number==0)
6925 sprintf(str_a,"Custom");
6926 else
6927 sprintf(str_a,"%d",QHeader.quest_number);
6928
6929 sprintf(str_s,"%s",VerStr(QHeader.zelda_version));
6930
6931 quest_dlg[11].d1 = quest_dlg[9].d1 = 0;
6932 quest_dlg[11].d2 = quest_dlg[9].d2 = 0;
6933
6934 if(is_large)
6935 large_dialog(quest_dlg);
6936
6937 zc_popup_dialog(quest_dlg, 0);
6938 return D_O_K;
6939 }
6940
6941 void call_vidmode_dlg();
6942 int32_t onVidMode()
6943 {
6944 call_vidmode_dlg();
6945 return D_O_K;
6946 }
6947
6948 #define addToHash(c,b,h) if(h->find(c ## key) == h->end()) \
6949 {(*h)[c ## key]=true;} else { if ( c ## key != 0 ) b = false;}
6950 //Added an extra statement, so that if the key is cleared to 0, the cleared
6951 //keybinding status need not be unique. -Z ( 1st April, 2019 )
6952
6953 void load_ukeys(int32_t* arr)
6954 {
6955 arr[ukey_a] = Akey;
6956 arr[ukey_b] = Bkey;
6957 arr[ukey_s] = Skey;
6958 arr[ukey_l] = Lkey;
6959 arr[ukey_r] = Rkey;
6960 arr[ukey_p] = Pkey;
6961 arr[ukey_ex1] = Exkey1;
6962 arr[ukey_ex2] = Exkey2;
6963 arr[ukey_ex3] = Exkey3;
6964 arr[ukey_ex4] = Exkey4;
6965 arr[ukey_du] = DUkey;
6966 arr[ukey_dd] = DDkey;
6967 arr[ukey_dl] = DLkey;
6968 arr[ukey_dr] = DRkey;
6969 arr[ukey_mod1a] = cheat_modifier_keys[0];
6970 arr[ukey_mod1b] = cheat_modifier_keys[1];
6971 arr[ukey_mod2a] = cheat_modifier_keys[2];
6972 arr[ukey_mod2b] = cheat_modifier_keys[3];
6973 };
6974
6975 static const char* ukey_names[] = {
6976 "A", "B", "Start", "L", "R", "Map",
6977 "Ex1", "Ex2", "Ex3", "Ex4", "Up", "Down",
6978 "Left", "Right", "Cheat Mod L1", "Cheat Mod L2",
6979 "Cheat Mod R1", "Cheat Mod R2",
6980 };
6981 std::string get_ukey_name(int32_t k)
6982 {
6983 if (k < num_ukey) return ukey_names[k];
6984 return "";
6985 }
6986
6987 int32_t onKeyboard()
6988 {
6989 int32_t a = Akey;
6990 int32_t b = Bkey;
6991 int32_t s = Skey;
6992 int32_t l = Lkey;
6993 int32_t r = Rkey;
6994 int32_t p = Pkey;
6995 int32_t ex1 = Exkey1;
6996 int32_t ex2 = Exkey2;
6997 int32_t ex3 = Exkey3;
6998 int32_t ex4 = Exkey4;
6999 int32_t du = DUkey;
7000 int32_t dd = DDkey;
7001 int32_t dl = DLkey;
7002 int32_t dr = DRkey;
7003 int32_t mod1a = cheat_modifier_keys[0];
7004 int32_t mod1b = cheat_modifier_keys[1];
7005 int32_t mod2a = cheat_modifier_keys[2];
7006 int32_t mod2b = cheat_modifier_keys[3];
7007 bool done=false;
7008 int32_t ret;
7009
7010 keyboard_control_dlg[0].dp2=lfont;
7011
7012 if(is_large)
7013 large_dialog(keyboard_control_dlg);
7014
7015 while(!done)
7016 {
7017 ret = zc_popup_dialog(keyboard_control_dlg,3);
7018
7019 if(ret==3) // OK
7020 {
7021 int32_t ukeys[num_ukey];
7022 load_ukeys(ukeys);
7023 std::vector<std::string> uniqueError;
7024 for(int32_t q = 0; q < num_ukey; ++q)
7025 {
7026 for(int32_t p = q+1; p < num_ukey; ++p)
7027 {
7028 if(ukeys[q] == ukeys[p] && ukeys[q] != 0)
7029 {
7030 char buf[64];
7031 sprintf(buf, "'%s' conflicts with '%s'", get_ukey_name(q).c_str(), get_ukey_name(p).c_str());
7032 std::string str(buf);
7033 uniqueError.push_back(str);
7034 }
7035 }
7036 }
7037 if(uniqueError.size() == 0)
7038 {
7039 done = true;
7040 save_control_configs(true);
7041 }
7042 else
7043 {
7044 box_start(1, "Duplicate Keys", lfont, sfont, false, keyboard_control_dlg[0].w,keyboard_control_dlg[0].h, 2);
7045 box_out("Cannot have duplicate keybinds!"); box_eol();
7046 for(std::vector<std::string>::iterator it = uniqueError.begin();
7047 it != uniqueError.end(); ++it)
7048 {
7049 box_out((*it).c_str()); box_eol();
7050 }
7051 box_end(true);
7052 }
7053 /* Old uniqueness check
7054 std::map<int32_t,bool> *keyhash = new std::map<int32_t,bool>();
7055 bool unique = true;
7056 addToHash(A,unique,keyhash);
7057 addToHash(B,unique,keyhash);
7058 addToHash(S,unique,keyhash);
7059 addToHash(L,unique,keyhash);
7060 addToHash(R,unique,keyhash);
7061 addToHash(P,unique,keyhash);
7062 addToHash(DU,unique,keyhash);
7063 addToHash(DD,unique,keyhash);
7064 addToHash(DL,unique,keyhash);
7065 addToHash(DR,unique,keyhash);
7066
7067 if(keyhash->find(Exkey1) == keyhash->end())
7068 {
7069 (*keyhash)[Exkey1]=true;
7070 }
7071 else
7072 {
7073 if ( Exkey1 != 0 ) unique = false;
7074 }
7075
7076 if(keyhash->find(Exkey2) == keyhash->end())
7077 {
7078 (*keyhash)[Exkey2]=true;
7079 }
7080 else
7081 {
7082 if ( Exkey2 != 0 ) unique = false;
7083 }
7084
7085 if(keyhash->find(Exkey3) == keyhash->end())
7086 {
7087 (*keyhash)[Exkey3]=true;
7088 }
7089 else
7090 {
7091 if ( Exkey3 != 0 ) unique = false;
7092 }
7093
7094 if(keyhash->find(Exkey4) == keyhash->end())
7095 {
7096 (*keyhash)[Exkey4]=true;
7097 }
7098 else
7099 {
7100 if ( Exkey4 != 0 )unique = false;
7101 }
7102 //modifier keys
7103 if(keyhash->find(cheat_modifier_keys[0]) == keyhash->end())
7104 {
7105 (*keyhash)[cheat_modifier_keys[0]]=true;
7106 }
7107 else
7108 {
7109 if ( cheat_modifier_keys[0] != 0 ) unique = false;
7110 }
7111 if(keyhash->find(cheat_modifier_keys[1]) == keyhash->end())
7112 {
7113 (*keyhash)[cheat_modifier_keys[1]]=true;
7114 }
7115 else
7116 {
7117 if ( cheat_modifier_keys[1] != 0 ) unique = false;
7118 }
7119 if(keyhash->find(cheat_modifier_keys[2]) == keyhash->end())
7120 {
7121 (*keyhash)[cheat_modifier_keys[2]]=true;
7122 }
7123 else
7124 {
7125 if ( cheat_modifier_keys[2] != 0 ) unique = false;
7126 }
7127 if(keyhash->find(cheat_modifier_keys[3]) == keyhash->end())
7128 {
7129 (*keyhash)[cheat_modifier_keys[3]]=true;
7130 }
7131 else
7132 {
7133 if ( cheat_modifier_keys[3] != 0 ) unique = false;
7134 }
7135
7136 delete keyhash;
7137
7138 if(unique)
7139 done=true;
7140 else
7141 jwin_alert("Error", "Key bindings must be unique!", "", "", "OK",NULL,'o',0,lfont);
7142 */
7143 }
7144 else // Cancel
7145 {
7146 Akey = a;
7147 Bkey = b;
7148 Skey = s;
7149 Lkey = l;
7150 Rkey = r;
7151 Pkey = p;
7152 Exkey1 = ex1;
7153 Exkey2 = ex2;
7154 Exkey3 = ex3;
7155 Exkey4 = ex4;
7156 DUkey = du;
7157 DDkey = dd;
7158 DLkey = dl;
7159 DRkey = dr;
7160 cheat_modifier_keys[0] = mod1a;
7161 cheat_modifier_keys[1] = mod1b;
7162 cheat_modifier_keys[2] = mod2a;
7163 cheat_modifier_keys[3] = mod2b;
7164
7165 done=true;
7166 }
7167
7168 rest(1);
7169 }
7170
7171 return D_O_K;
7172 }
7173
7174 int32_t onGamepad()
7175 {
7176 int32_t a = Abtn;
7177 int32_t b = Bbtn;
7178 int32_t s = Sbtn;
7179 int32_t l = Lbtn;
7180 int32_t r = Rbtn;
7181 int32_t m = Mbtn;
7182 int32_t p = Pbtn;
7183 int32_t ex1 = Exbtn1;
7184 int32_t ex2 = Exbtn2;
7185 int32_t ex3 = Exbtn3;
7186 int32_t ex4 = Exbtn4;
7187 int32_t up = DUbtn;
7188 int32_t down = DDbtn;
7189 int32_t left = DLbtn;
7190 int32_t right = DRbtn;
7191
7192 gamepad_dlg[0].dp2=lfont;
7193 if(analog_movement)
7194 gamepad_dlg[56].flags|=D_SELECTED;
7195 else
7196 gamepad_dlg[56].flags&=~D_SELECTED;
7197
7198 if(is_large)
7199 large_dialog(gamepad_dlg);
7200
7201 int32_t ret = zc_popup_dialog(gamepad_dlg,4);
7202
7203 if(ret == 4) //OK
7204 {
7205 analog_movement = gamepad_dlg[56].flags&D_SELECTED;
7206 save_control_configs(false);
7207 }
7208 else //Cancel
7209 {
7210 Abtn = a;
7211 Bbtn = b;
7212 Sbtn = s;
7213 Lbtn = l;
7214 Rbtn = r;
7215 Mbtn = m;
7216 Pbtn = p;
7217 Exbtn1 = ex1;
7218 Exbtn2 = ex2;
7219 Exbtn3 = ex3;
7220 Exbtn4 = ex4;
7221 DUbtn = up;
7222 DDbtn = down;
7223 DLbtn = left;
7224 DRbtn = right;
7225 }
7226
7227 return D_O_K;
7228 }
7229
7230 int32_t onSound()
7231 {
7232 if ( FFCore.coreflags&FFCORE_SCRIPTED_MIDI_VOLUME )
7233 {
7234 master_volume(-1,((int32_t)FFCore.usr_midi_volume));
7235 }
7236 if ( FFCore.coreflags&FFCORE_SCRIPTED_DIGI_VOLUME )
7237 {
7238 master_volume((int32_t)(FFCore.usr_digi_volume),1);
7239 }
7240 if ( FFCore.coreflags&FFCORE_SCRIPTED_MUSIC_VOLUME )
7241 {
7242 emusic_volume = (int32_t)FFCore.usr_music_volume;
7243 }
7244 if ( FFCore.coreflags&FFCORE_SCRIPTED_SFX_VOLUME )
7245 {
7246 sfx_volume = (int32_t)FFCore.usr_sfx_volume;
7247 }
7248 if ( FFCore.coreflags&FFCORE_SCRIPTED_PANSTYLE )
7249 {
7250 pan_style = (int32_t)FFCore.usr_panstyle;
7251 }
7252
7253 int32_t m = midi_volume;
7254 int32_t d = digi_volume;
7255 int32_t e = emusic_volume;
7256 int32_t b = zcmusic_bufsz;
7257 int32_t s = sfx_volume;
7258 int32_t p = pan_style;
7259 pan_style = vbound(pan_style,0,3);
7260
7261 sound_dlg[0].dp2=lfont;
7262
7263 if(is_large)
7264 large_dialog(sound_dlg);
7265
7266 midi_dp[1] = sound_dlg[6].x;
7267 midi_dp[2] = sound_dlg[6].y;
7268 digi_dp[1] = sound_dlg[7].x;
7269 digi_dp[2] = sound_dlg[7].y;
7270 emus_dp[1] = sound_dlg[8].x;
7271 emus_dp[2] = sound_dlg[8].y;
7272 buf_dp[1] = sound_dlg[9].x;
7273 buf_dp[2] = sound_dlg[9].y;
7274 sfx_dp[1] = sound_dlg[10].x;
7275 sfx_dp[2] = sound_dlg[10].y;
7276 pan_dp[1] = sound_dlg[11].x;
7277 pan_dp[2] = sound_dlg[11].y;
7278 sound_dlg[15].d2 = (midi_volume==255) ? 32 : midi_volume>>3;
7279 sound_dlg[16].d2 = (digi_volume==255) ? 32 : digi_volume>>3;
7280 sound_dlg[17].d2 = (emusic_volume==255) ? 32 : emusic_volume>>3;
7281 sound_dlg[18].d2 = zcmusic_bufsz;
7282 sound_dlg[19].d2 = (sfx_volume==255) ? 32 : sfx_volume>>3;
7283 sound_dlg[20].d2 = pan_style;
7284
7285 int32_t ret = zc_popup_dialog(sound_dlg,1);
7286
7287 if(ret==2)
7288 {
7289 master_volume(digi_volume,midi_volume);
7290
7291 for(int32_t i=0; i<WAV_COUNT; ++i)
7292 {
7293 //allegro assertion fails when passing in -1 as voice -DD
7294 if(sfx_voice[i] > 0)
7295 voice_set_volume(sfx_voice[i], sfx_volume);
7296 }
7297 zc_set_config(sfx_sect,"digi",digi_volume);
7298 zc_set_config(sfx_sect,"midi",midi_volume);
7299 zc_set_config(sfx_sect,"sfx",sfx_volume);
7300 zc_set_config(sfx_sect,"emusic",emusic_volume);
7301 zc_set_config(sfx_sect,"pan",pan_style);
7302 zc_set_config(sfx_sect,"zcmusic_bufsz",zcmusic_bufsz);
7303 }
7304 else
7305 {
7306 midi_volume = m;
7307 digi_volume = d;
7308 emusic_volume = e;
7309 zcmusic_bufsz = b;
7310 sfx_volume = s;
7311 pan_style = p;
7312 }
7313
7314 return D_O_K;
7315 }
7316
7317 int32_t queding(char const* s1, char const* s2, char const* s3)
7318 {
7319 return jwin_alert(ZC_str,s1,s2,s3,"&Yes","&No",'y','n',lfont);
7320 }
7321
7322 int32_t onQuit()
7323 {
7324 if(Playing)
7325 {
7326 int32_t ret=0;
7327
7328 if(get_bit(quest_rules, qr_NOCONTINUE))
7329 {
7330 if(standalone_mode)
7331 {
7332 ret=queding("End current game?",
7333 "The continue screen is disabled; the game",
7334 "will be reloaded from the last save.");
7335 }
7336 else
7337 {
7338 ret=queding("End current game?",
7339 "The continue screen is disabled. You will",
7340 "be returned to the file select screen.");
7341 }
7342 }
7343 else
7344 ret=queding("End current game?",NULL,NULL);
7345
7346 if(ret==1)
7347 {
7348 disableClickToFreeze=false;
7349 Quit=qQUIT;
7350
7351 // Trying to evade a door repair charge?
7352 if(repaircharge)
7353 {
7354 game->change_drupy(-repaircharge);
7355 repaircharge=0;
7356 }
7357
7358 return D_CLOSE;
7359 }
7360 }
7361
7362 return D_O_K;
7363 }
7364
7365 int32_t onTryQuitMenu()
7366 {
7367 return onTryQuit(true);
7368 }
7369
7370 int32_t onTryQuit(bool inMenu)
7371 {
7372 if(Playing && !(GameFlags & GAMEFLAG_NO_F6))
7373 {
7374 if(get_bit(quest_rules,qr_OLD_F6))
7375 {
7376 if(inMenu) onQuit();
7377 else /*if(!get_bit(quest_rules, qr_NOCONTINUE))*/ f_Quit(qQUIT);
7378 }
7379 else
7380 {
7381 disableClickToFreeze=false;
7382 GameFlags |= GAMEFLAG_TRYQUIT;
7383 }
7384 return D_CLOSE;
7385 }
7386
7387 return D_O_K;
7388 }
7389
7390 int32_t onReset()
7391 {
7392 if(queding(" Reset system? ",NULL,NULL)==1)
7393 {
7394 disableClickToFreeze=false;
7395 Quit=qRESET;
7396 replay_quit();
7397 return D_CLOSE;
7398 }
7399
7400 return D_O_K;
7401 }
7402
7403 int32_t onExit()
7404 {
7405 if(queding(" Quit Zelda Classic? ",NULL,NULL)==1)
7406 {
7407 Quit=qEXIT;
7408 return D_CLOSE;
7409 }
7410
7411 return D_O_K;
7412 }
7413
7414 int32_t onTitle_NES()
7415 {
7416 title_version=0;
7417 zc_set_config(cfg_sect,"title",title_version);
7418 return D_O_K;
7419 }
7420 int32_t onTitle_DX()
7421 {
7422 title_version=1;
7423 zc_set_config(cfg_sect,"title",title_version);
7424 return D_O_K;
7425 }
7426 int32_t onTitle_25()
7427 {
7428 title_version=2;
7429 zc_set_config(cfg_sect,"title",title_version);
7430 return D_O_K;
7431 }
7432
7433 int32_t onDebug()
7434 {
7435 if(debug_enabled)
7436 set_debug(!get_debug());
7437 return D_O_K;
7438 }
7439
7440 int32_t onHeartBeep()
7441 {
7442 heart_beep=!heart_beep;
7443 zc_set_config(cfg_sect,"heart_beep",heart_beep);
7444 return D_O_K;
7445 }
7446
7447 int32_t onSaveIndicator()
7448 {
7449 use_save_indicator=!use_save_indicator;
7450 zc_set_config(cfg_sect,"save_indicator",use_save_indicator);
7451 return D_O_K;
7452 }
7453
7454 int32_t onEpilepsy()
7455 {
7456 if(jwin_alert3(
7457 "Epilepsy Flash Reduction",
7458 "Enabling this will reduce the intensity of flashing and screen wave effects.",
7459 "Disabling this will restore standard flash and wavy behaviour.",
7460 "Proceed?",
7461 "&Yes",
7462 "&No",
7463 NULL,
7464 'y',
7465 'n',
7466 0,
7467 lfont) == 1)
7468 {
7469 epilepsyFlashReduction = epilepsyFlashReduction ? 0 : 1;
7470 zc_set_config("zeldadx","checked_epilepsy",1);
7471 zc_set_config(cfg_sect,"epilepsy_flash_reduction",epilepsyFlashReduction);
7472 }
7473 return D_O_K;
7474 }
7475
7476 int32_t onTriforce()
7477 {
7478 for(int32_t i=0; i<MAXINITTABS; ++i)
7479 {
7480 init_tabs[i].flags&=~D_SELECTED;
7481 }
7482
7483 init_tabs[3].flags=D_SELECTED;
7484 return onCheatConsole();
7485 /*triforce_dlg[0].dp2=lfont;
7486 for(int32_t i=1; i<=8; i++)
7487 triforce_dlg[i].flags = (game->lvlitems[i] & liTRIFORCE) ? D_SELECTED : 0;
7488
7489 if(zc_popup_dialog (triforce_dlg,-1)==9)
7490 {
7491 for(int32_t i=1; i<=8; i++)
7492 {
7493 game->lvlitems[i] &= ~liTRIFORCE;
7494 game->lvlitems[i] |= (triforce_dlg[i].flags & D_SELECTED) ? liTRIFORCE : 0;
7495 }
7496 }
7497 return D_O_K;*/
7498 }
7499
7500 bool rc = false;
7501 /*
7502 int32_t onEquipment()
7503 {
7504 for (int32_t i=0; i<MAXINITTABS; ++i)
7505 {
7506 init_tabs[i].flags&=~D_SELECTED;
7507 }
7508 init_tabs[0].flags=D_SELECTED;
7509 return onCheatConsole();
7510 }
7511 */
7512
7513 int32_t onItems()
7514 {
7515 for(int32_t i=0; i<MAXINITTABS; ++i)
7516 {
7517 init_tabs[i].flags&=~D_SELECTED;
7518 }
7519
7520 init_tabs[1].flags=D_SELECTED;
7521 return onCheatConsole();
7522 }
7523
7524 static DIALOG getnum_dlg[] =
7525 {
7526 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
7527 { jwin_win_proc, 80, 80, 160, 72, vc(0), vc(11), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
7528 { jwin_text_proc, 104, 104+4, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
7529 { jwin_edit_proc, 168, 104, 48, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
7530 { jwin_button_proc, 90, 126, 61, 21, vc(0), vc(11), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7531 { jwin_button_proc, 170, 126, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7532 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7533 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7534 };
7535
7536 int32_t getnumber(const char *prompt,int32_t initialval)
7537 {
7538 char buf[20];
7539 sprintf(buf,"%d",initialval);
7540 getnum_dlg[0].dp=(void *)prompt;
7541 getnum_dlg[0].dp2=lfont;
7542 getnum_dlg[2].dp=buf;
7543
7544 if(is_large)
7545 large_dialog(getnum_dlg);
7546
7547 if(zc_popup_dialog(getnum_dlg,2)==3)
7548 return atoi(buf);
7549
7550 return initialval;
7551 }
7552
7553 int32_t onLife()
7554 {
7555 int value = vbound(getnumber("Life",game->get_life()),1,game->get_maxlife());
7556 cheats_enqueue(Cheat::Life, value);
7557 return D_O_K;
7558 }
7559
7560 int32_t onHeartC()
7561 {
7562 int max_life = vbound(getnumber("Heart Containers",game->get_maxlife()/game->get_hp_per_heart()),1,4095) * game->get_hp_per_heart();
7563 int life = vbound(getnumber("Life",game->get_life()/game->get_hp_per_heart()),1,max_life/game->get_hp_per_heart())*game->get_hp_per_heart();
7564 cheats_enqueue(Cheat::MaxLife, max_life);
7565 cheats_enqueue(Cheat::Life, life);
7566 return D_O_K;
7567 }
7568
7569 int32_t onMagicC()
7570 {
7571 int max_magic = vbound(getnumber("Magic Containers",game->get_maxmagic()/game->get_mp_per_block()),0,2047) * game->get_mp_per_block();
7572 int magic = vbound(getnumber("Magic",game->get_magic()/game->get_mp_per_block()),0,game->get_maxmagic()/game->get_mp_per_block())*game->get_mp_per_block();
7573 cheats_enqueue(Cheat::MaxMagic, max_magic);
7574 cheats_enqueue(Cheat::Magic, magic);
7575 return D_O_K;
7576 }
7577
7578 int32_t onRupies()
7579 {
7580 int value = vbound(getnumber("Rupees",game->get_rupies()),0,game->get_maxcounter(1));
7581 cheats_enqueue(Cheat::Rupies, value);
7582 return D_O_K;
7583 }
7584
7585 int32_t onMaxBombs()
7586 {
7587 int value = vbound(getnumber("Max Bombs",game->get_maxbombs()),0,0xFFFF);
7588 cheats_enqueue(Cheat::MaxBombs, value);
7589 cheats_enqueue(Cheat::Bombs, value);
7590 return D_O_K;
7591 }
7592
7593 int32_t onRefillLife()
7594 {
7595 cheats_enqueue(Cheat::Life, game->get_maxlife());
7596 return D_O_K;
7597 }
7598 int32_t onRefillMagic()
7599 {
7600 cheats_enqueue(Cheat::Magic, game->get_maxmagic());
7601 return D_O_K;
7602 }
7603 int32_t onClock()
7604 {
7605 cheats_enqueue(Cheat::Clock);
7606 return D_O_K;
7607 }
7608
7609 int32_t onQstPath()
7610 {
7611 char path[2048];
7612
7613 chop_path(qstdir);
7614 strcpy(path,qstdir);
7615
7616 go();
7617
7618 if(jwin_dfile_select_ex("Quest File Directory", path, "qst", 2048, -1, -1, lfont))
7619 {
7620 chop_path(path);
7621 fix_filename_case(path);
7622 fix_filename_slashes(path);
7623 strcpy(qstdir,path);
7624 strcpy(qstpath,qstdir);
7625 }
7626
7627 comeback();
7628 return D_O_K;
7629 }
7630
7631 #include "dialog/cheat_dialog.h"
7632 int32_t onCheat()
7633 {
7634 call_setcheat_dialog();
7635 game->set_cheat(maxcheat);
7636 if(cheat) game->did_cheat(true);
7637 return D_O_K;
7638 }
7639
7640 int32_t onCheatRupies()
7641 {
7642 cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
7643 return D_O_K;
7644 }
7645
7646 int32_t onCheatArrows()
7647 {
7648 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
7649 return D_O_K;
7650 }
7651
7652 int32_t onCheatBombs()
7653 {
7654 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
7655 return D_O_K;
7656 }
7657
7658 // *** screen saver
7659
7660 4800616 int32_t after_time()
7661 {
7662
1/2
✓ Branch 0 taken 4800616 times.
✗ Branch 1 not taken.
4800616 if(ss_enable == 0)
7663 return INT_MAX;
7664
7665
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4800616 times.
4800616 if(ss_after <= 0)
7666 return 5 * 60;
7667
7668
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4800616 times.
4800616 if(ss_after <= 3)
7669 return ss_after * 15 * 60;
7670
7671
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4800616 times.
4800616 if(ss_after <= 13)
7672 return (ss_after - 3) * 60 * 60;
7673
7674 4800616 return MAX_IDLE + 1;
7675 4800616 }
7676
7677 static const char *after_str[15] =
7678 {
7679 " 5 sec", "15 sec", "30 sec", "45 sec", " 1 min", " 2 min", " 3 min",
7680 " 4 min", " 5 min", " 6 min", " 7 min", " 8 min", " 9 min", "10 min",
7681 "Never"
7682 };
7683
7684 const char *after_list(int32_t index, int32_t *list_size)
7685 {
7686 if(index < 0)
7687 {
7688 *list_size = 15;
7689 return NULL;
7690 }
7691
7692 return after_str[index];
7693 }
7694
7695 28 static ListData after__list(after_list, &font);
7696
7697 static DIALOG scrsaver_dlg[] =
7698 {
7699 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
7700 28 { jwin_win_proc, 32, 64, 256, 136, 0, 0, 0, D_EXIT, 0, 0, (void *) "Screen Saver Settings", NULL, NULL },
7701 28 { jwin_frame_proc, 42, 92, 236, 70, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
7702 28 { jwin_text_proc, 60, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Run After", NULL, NULL },
7703 28 { jwin_text_proc, 60, 128, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Speed", NULL, NULL },
7704 28 { jwin_text_proc, 60, 144, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Density", NULL, NULL },
7705 28 { jwin_droplist_proc, 144, 100, 96, 16, 0, 0, 0, 0, 0, 0, (void *) &after__list, NULL, NULL },
7706 28 { jwin_slider_proc, 144, 128, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7707 28 { jwin_slider_proc, 144, 144, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7708 28 { jwin_button_proc, 42, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7709 28 { jwin_button_proc, 124, 170, 72, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Preview", NULL, NULL },
7710 28 { jwin_button_proc, 218, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7711 28 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7712 28 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7713 };
7714
7715 int32_t onScreenSaver()
7716 {
7717 scrsaver_dlg[0].dp2=lfont;
7718 int32_t oldcfgs[3];
7719 scrsaver_dlg[5].d1 = scrsaver_dlg[5].d2 = oldcfgs[0] = ss_after;
7720 scrsaver_dlg[6].d2 = oldcfgs[1] = ss_speed;
7721 scrsaver_dlg[7].d2 = oldcfgs[2] = ss_density;
7722
7723 if(is_large)
7724 large_dialog(scrsaver_dlg);
7725
7726 int32_t ret = zc_popup_dialog(scrsaver_dlg,-1);
7727
7728 if(ret == 8 || ret == 9)
7729 {
7730 ss_after = scrsaver_dlg[5].d1;
7731 ss_speed = scrsaver_dlg[6].d2;
7732 ss_density = scrsaver_dlg[7].d2;
7733 if(oldcfgs[0] != ss_after)
7734 zc_set_config(cfg_sect,"ss_after",ss_after);
7735 if(oldcfgs[1] != ss_speed)
7736 zc_set_config(cfg_sect,"ss_speed",ss_speed);
7737 if(oldcfgs[2] != ss_density)
7738 zc_set_config(cfg_sect,"ss_density",ss_density);
7739 }
7740
7741 if(ret == 9)
7742 // preview Screen Saver
7743 {
7744 clear_keybuf();
7745 scare_mouse();
7746 Matrix(ss_speed, ss_density, 30);
7747 system_pal();
7748 unscare_mouse();
7749 }
7750
7751 return D_O_K;
7752 }
7753
7754 /***** Menus *****/
7755
7756 static MENU game_menu[] =
7757 {
7758 { (char *)"&Continue\tESC", onContinue, NULL, 0, NULL },
7759 { (char *)"", NULL, NULL, 0, NULL },
7760 { (char *)"L&oad Quest...", onCustomGame, NULL, 0, NULL },
7761 { (char *)"&End Game\tF6", onTryQuitMenu, NULL, 0, NULL },
7762 { (char *)"", NULL, NULL, 0, NULL },
7763 #ifdef __EMSCRIPTEN__
7764 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7765 #elif defined(ALLEGRO_MACOSX)
7766 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7767 { (char *)"&Quit\tF8", onExit, NULL, 0, NULL },
7768 #else
7769 { (char *)"&Reset\tF9", onReset, NULL, 0, NULL },
7770 { (char *)"&Quit\tF10", onExit, NULL, 0, NULL },
7771 #endif
7772 { NULL, NULL, NULL, 0, NULL }
7773 };
7774
7775 static MENU title_menu[] =
7776 {
7777 { (char *)"&Original", onTitle_NES, NULL, 0, NULL },
7778 { (char *)"&Zelda Classic", onTitle_DX, NULL, 0, NULL },
7779 { (char *)"Zelda Classic &2.50", onTitle_25, NULL, 0, NULL },
7780 { NULL, NULL, NULL, 0, NULL }
7781 };
7782
7783 static MENU snapshot_format_menu[] =
7784 {
7785 { (char *)"&BMP", onSetSnapshotFormat, NULL, 0, NULL },
7786 { (char *)"&GIF", onSetSnapshotFormat, NULL, 0, NULL },
7787 { (char *)"&JPG", onSetSnapshotFormat, NULL, 0, NULL },
7788 { (char *)"&PNG", onSetSnapshotFormat, NULL, 0, NULL },
7789 { (char *)"PC&X", onSetSnapshotFormat, NULL, 0, NULL },
7790 { (char *)"&TGA", onSetSnapshotFormat, NULL, 0, NULL },
7791 { NULL, NULL, NULL, 0, NULL }
7792 };
7793
7794 static MENU controls_menu[] =
7795 {
7796 { (char *)"Key&board...", onKeyboard, NULL, 0, NULL },
7797 { (char *)"&Gamepad...", onGamepad, NULL, 0, NULL },
7798 { NULL, NULL, NULL, 0, NULL }
7799 };
7800
7801 static MENU name_entry_mode_menu[] =
7802 {
7803 { (char *)"&Keyboard", onKeyboardEntry, NULL, 0, NULL },
7804 { (char *)"&Letter Grid", onLetterGridEntry, NULL, 0, NULL },
7805 { (char *)"&Extended Letter Grid", onExtLetterGridEntry, NULL, 0, NULL },
7806 { NULL, NULL, NULL, 0, NULL }
7807 };
7808
7809 static void set_controls_menu_active()
7810 {
7811
7812 }
7813
7814 static MENU settings_menu[] =
7815 {
7816 { (char *)"&Sound...", onSound, NULL, 0, NULL },
7817 { (char *)"C&ontrols", NULL, controls_menu, 0, NULL },
7818 { (char *)"&Title Screen", NULL, title_menu, 0, NULL },
7819 { (char *)"Name &Entry Mode", NULL, name_entry_mode_menu, 0, NULL },
7820 { (char *)"", NULL, NULL, 0, NULL },
7821 { (char *)"&Cap FPS\tF1", onVsync, NULL, 0, NULL },
7822 { (char *)"Show &FPS\tF2", onShowFPS, NULL, 0, NULL },
7823 { (char *)"Show Trans. &Layers", onTransLayers, NULL, 0, NULL },
7824 { (char *)"Up+A+B To &Quit", onNESquit, NULL, 0, NULL },
7825 { (char *)"Click to Freeze", onClickToFreeze, NULL, 0, NULL },
7826 { (char *)"Autosave Window Size Changes", onSaveDragResize, NULL, 0, NULL },
7827 { (char *)"Lock Aspect Ratio", onDragAspect, NULL, 0, NULL },
7828 { (char *)"Window Position Saving", onWinPosSave, NULL, 0, NULL },
7829 { (char *)"Volume &Keys", onVolKeys, NULL, 0, NULL },
7830 { (char *)"Cont. &Heart Beep", onHeartBeep, NULL, 0, NULL },
7831 { (char *)"Sa&ve Indicator", onSaveIndicator, NULL, 0, NULL },
7832 { (char *)"Epilepsy Flash Reduction", onEpilepsy, NULL, 0, NULL },
7833 { (char *)"S&napshot Format", NULL, snapshot_format_menu, 0, NULL },
7834 { (char *)"", NULL, NULL, 0, NULL },
7835 { (char *)"Debu&g", onDebug, NULL, 0, NULL },
7836 { (char *)"", NULL, NULL, 0, NULL },
7837 { NULL, NULL, NULL, 0, NULL }
7838 };
7839
7840
7841 static MENU misc_menu[] =
7842 {
7843 { (char *)"&About...", onAbout, NULL, 0, NULL },
7844 { (char *)"&Credits...", onCredits, NULL, 0, NULL },
7845 { (char *)"&Fullscreen", onFullscreenMenu, NULL, 0, NULL },
7846 { (char *)"&Video Mode...", onVidMode, NULL, 0, NULL },
7847 { (char *)"", NULL, NULL, 0, NULL },
7848 //5
7849 { (char *)"&Quest Info...", onQuest, NULL, 0, NULL },
7850 { (char *)"Quest &MIDI Info...", onMIDICredits, NULL, 0, NULL },
7851 { (char *)"Quest &Directory...", onQstPath, NULL, 0, NULL },
7852 { (char *)"", NULL, NULL, 0, NULL },
7853 { (char *)"Take &Snapshot\tF12", onSnapshot, NULL, 0, NULL },
7854 //10
7855 { (char *)"Sc&reen Saver...", onScreenSaver, NULL, 0, NULL },
7856 { (char *)"Save ZC Configuration", OnSaveZCConfig, NULL, 0, NULL },
7857 { (char *)"Show ZASM Debugger", onConsoleZASM, NULL, 0, NULL },
7858 { (char *)"Show ZScript Debugger", onConsoleZScript, NULL, 0, NULL },
7859 { (char *)"Clear Console on Qst Load", onClrConsoleOnLoad, NULL, 0, NULL },
7860 //15
7861 { (char *)"Clear Directory Cache", OnnClearQuestDir, NULL, 0, NULL },
7862 { (char *)"Modules", NULL, zcmodule_menu, 0, NULL },
7863 { (char *)"Replay", NULL, replay_menu, 0, NULL },
7864
7865 { NULL, NULL, NULL, 0, NULL }
7866 };
7867
7868 static MENU refill_menu[] =
7869 {
7870 { (char *)"&Life\t*, H", onRefillLife, NULL, 0, NULL },
7871 { (char *)"&Magic\t/, M", onRefillMagic, NULL, 0, NULL },
7872 { (char *)"&Bombs\tB", onCheatBombs, NULL, 0, NULL },
7873 { (char *)"&Rupees\tR", onCheatRupies, NULL, 0, NULL },
7874 { (char *)"&Arrows\tA", onCheatArrows, NULL, 0, NULL },
7875 { NULL, NULL, NULL, 0, NULL }
7876 };
7877
7878 static MENU show_menu[] =
7879 {
7880 { (char *)"Combos\t0", onShowLayer0, NULL, 0, NULL },
7881 { (char *)"Layer 1\t1", onShowLayer1, NULL, 0, NULL },
7882 { (char *)"Layer 2\t2", onShowLayer2, NULL, 0, NULL },
7883 { (char *)"Layer 3\t3", onShowLayer3, NULL, 0, NULL },
7884 { (char *)"Layer 4\t4", onShowLayer4, NULL, 0, NULL },
7885 { (char *)"Layer 5\t5", onShowLayer5, NULL, 0, NULL },
7886 { (char *)"Layer 6\t6", onShowLayer6, NULL, 0, NULL },
7887 { (char *)"Overhead Combos\tO", onShowLayerO, NULL, 0, NULL },
7888 { (char *)"Push Blocks\tP", onShowLayerP, NULL, 0, NULL },
7889 { (char *)"Freeform Combos\t7", onShowLayerF, NULL, 0, NULL },
7890 { (char *)"Sprites\t8", onShowLayerS, NULL, 0, NULL },
7891 { (char *)"", NULL, NULL, 0, NULL },
7892 { (char *)"Walkability\tW", onShowLayerW, NULL, 0, NULL },
7893 { (char *)"Current FFC Scripts\tF", onShowFFScripts, NULL, 0, NULL },
7894 { (char *)"Hitboxes\tC", onShowHitboxes, NULL, 0, NULL },
7895 { (char *)"Effects\tE", onShowLayerE, NULL, 0, NULL },
7896 { NULL, NULL, NULL, 0, NULL }
7897 };
7898
7899 static MENU cheat_menu[] =
7900 {
7901 { (char *)"S&et Cheat", onCheat, NULL, 0, NULL },
7902 { (char *)"", NULL, NULL, 0, NULL },
7903 { (char *)"Re&fill", NULL, refill_menu, 0, NULL },
7904 { (char *)"", NULL, NULL, 0, NULL },
7905 { (char *)"&Clock\tI", onClock, NULL, 0, NULL },
7906 { (char *)"Ma&x Bombs...", onMaxBombs, NULL, 0, NULL },
7907 { (char *)"&Heart Containers...", onHeartC, NULL, 0, NULL },
7908 { (char *)"&Magic Containers...", onMagicC, NULL, 0, NULL },
7909 { (char *)"", NULL, NULL, 0, NULL },
7910 { (char *)"&Player Data...", onCheatConsole, NULL, 0, NULL },
7911 { (char *)"", NULL, NULL, 0, NULL },
7912 { (char *)"Walk Through &Walls\tF11", onNoWalls, NULL, 0, NULL },
7913 { (char *)"Player Ignores Side&view\tV", onIgnoreSideview, NULL, 0, NULL },
7914 { (char *)"&Quick Movement\tQ", onGoFast, NULL, 0, NULL },
7915 { (char *)"&Kill All Enemies\tK", onKillCheat, NULL, 0, NULL },
7916 { (char *)"Show/Hide Layer", NULL, show_menu, 0, NULL },
7917 { (char *)"Toggle Light\tL", onLightSwitch, NULL, 0, NULL },
7918 { (char *)"&Goto Location...\tG", onGoTo, NULL, 0, NULL },
7919 { NULL, NULL, NULL, 0, NULL }
7920 };
7921
7922 static MENU fixes_menu[] =
7923 {
7924 { (char *)"Windows MIDI Patch", onMIDIPatch, NULL, 0, NULL },
7925 { NULL, NULL, NULL, 0, NULL }
7926 };
7927
7928 #if DEVLEVEL > 0
7929 int32_t devLogging();
7930 int32_t devDebug();
7931 int32_t devTimestmp();
7932 #if DEVLEVEL > 1
7933 int32_t setCheat();
7934 #endif //DEVLEVEL > 1
7935 enum
7936 {
7937 dv_log,
7938 // dv_dbg,
7939 dv_tmpstmp,
7940 #if DEVLEVEL > 1
7941 dv_nil,
7942 dv_setcheat,
7943 #endif //DEVLEVEL > 1
7944 dv_max
7945 };
7946 static MENU dev_menu[] =
7947 {
7948 { (char *)"&Force Error Log", devLogging, NULL, 0, NULL },
7949 // { (char *)"&Extra Debug Log", devDebug, NULL, 0, NULL },
7950 { (char *)"&Timestamp Log", devTimestmp, NULL, 0, NULL },
7951 #if DEVLEVEL > 1
7952 { (char *)"", NULL, NULL, 0, NULL },
7953 { (char *)"Set &Cheat", setCheat, NULL, 0, NULL },
7954 #endif //DEVLEVEL > 1
7955 { NULL, NULL, NULL, 0, NULL }
7956 };
7957 int32_t devLogging()
7958 {
7959 dev_logging = !dev_logging;
7960 dev_menu[dv_log].flags = dev_logging ? D_SELECTED : 0;
7961 return D_O_K;
7962 }
7963 // int32_t devDebug()
7964 // {
7965 // dev_debug = !dev_debug;
7966 // dev_menu[dv_dbg].flags = dev_debug ? D_SELECTED : 0;
7967 // return D_O_K;
7968 // }
7969 int32_t devTimestmp()
7970 {
7971 dev_timestmp = !dev_timestmp;
7972 dev_menu[dv_tmpstmp].flags = dev_timestmp ? D_SELECTED : 0;
7973 return D_O_K;
7974 }
7975 #if DEVLEVEL > 1
7976 int32_t setCheat()
7977 {
7978 cheat = (vbound(getnumber("Cheat Level",cheat), 0, 4));
7979 return D_O_K;
7980 }
7981 #endif //DEVLEVEL > 1
7982 #endif //DEVLEVEL > 0
7983
7984 MENU the_player_menu[] =
7985 {
7986 { (char *)"&Game", NULL, game_menu, 0, NULL },
7987 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
7988 { (char *)"&Cheat", NULL, cheat_menu, 0, NULL },
7989 { (char *)"&Fixes", NULL, fixes_menu, 0, NULL },
7990 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
7991 #if DEVLEVEL > 0
7992 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
7993 #endif
7994 { NULL, NULL, NULL, 0, NULL }
7995 };
7996
7997 MENU the_player_menu2[] =
7998 {
7999 { (char *)"&Game", NULL, game_menu, 0, NULL },
8000 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
8001 { (char *)"&Fixes", NULL, fixes_menu, 0, NULL },
8002 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
8003 #if DEVLEVEL > 0
8004 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
8005 #endif
8006 { NULL, NULL, NULL, 0, NULL }
8007 };
8008
8009 int32_t onMIDIPatch()
8010 {
8011 if(jwin_alert3(
8012 "Toggle Windows MIDI Fix",
8013 "This action will change whether ZC Player auto-restarts a MIDI at its",
8014 "last index if you move ZC Player out of focus, then back into focus.",
8015 "Proceed?",
8016 "&Yes",
8017 "&No",
8018 NULL,
8019 'y',
8020 'n',
8021 0,
8022 lfont) == 1)
8023 {
8024 midi_patch_fix = midi_patch_fix ? 0 : 1;
8025 zc_set_config("zeldadx","midi_patch_fix",midi_patch_fix);
8026 }
8027 fixes_menu[0].flags =(midi_patch_fix)?D_SELECTED:0;
8028 return D_O_K;
8029 }
8030
8031 int32_t onKeyboardEntry()
8032 {
8033 NameEntryMode=0;
8034 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
8035 return D_O_K;
8036 }
8037
8038 int32_t onLetterGridEntry()
8039 {
8040 NameEntryMode=1;
8041 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
8042 return D_O_K;
8043 }
8044
8045 int32_t onExtLetterGridEntry()
8046 {
8047 NameEntryMode=2;
8048 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
8049 return D_O_K;
8050 }
8051
8052 static BITMAP* oldscreen;
8053 int32_t onFullscreenMenu()
8054 {
8055 // super hacks
8056 screen = oldscreen;
8057 if (onFullscreen() == D_REDRAW)
8058 {
8059 oldscreen = screen;
8060 }
8061 screen = menu_bmp;
8062 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
8063 return D_O_K;
8064 }
8065
8066 28 void fix_menu()
8067 {
8068
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
28 if(!debug_enabled)
8069 28 settings_menu[18].text = NULL;
8070 28 }
8071
8072 static DIALOG system_dlg[] =
8073 {
8074 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
8075 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu, NULL, NULL },
8076 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
8077 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
8078 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
8079 #ifndef ALLEGRO_MACOSX
8080 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
8081 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
8082 #else
8083 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
8084 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
8085 #endif
8086 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
8087 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
8088 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
8089 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
8090 };
8091
8092 static DIALOG system_dlg2[] =
8093 {
8094 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
8095 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu2, NULL, NULL },
8096 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
8097 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
8098 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
8099 #ifndef ALLEGRO_MACOSX
8100 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
8101 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
8102 #else
8103 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
8104 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
8105 #endif
8106 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
8107 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
8108 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
8109 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
8110 };
8111
8112 void reset_snapshot_format_menu()
8113 {
8114 for(int32_t i=0; i<ssfmtMAX; ++i)
8115 {
8116 snapshot_format_menu[i].flags=0;
8117 }
8118 }
8119
8120 int32_t onSetSnapshotFormat()
8121 {
8122 switch(active_menu->text[1])
8123 {
8124 case 'B': //"&BMP"
8125 SnapshotFormat=0;
8126 break;
8127
8128 case 'G': //"&GIF"
8129 SnapshotFormat=1;
8130 break;
8131
8132 case 'J': //"&JPG"
8133 SnapshotFormat=2;
8134 break;
8135
8136 case 'P': //"&PNG"
8137 SnapshotFormat=3;
8138 break;
8139
8140 case 'C': //"PC&X"
8141 SnapshotFormat=4;
8142 break;
8143
8144 case 'T': //"&TGA"
8145 SnapshotFormat=5;
8146 break;
8147
8148 case 'L': //"&LBM"
8149 SnapshotFormat=6;
8150 break;
8151 }
8152 zc_set_config("zeldadx", "snapshot_format", SnapshotFormat);
8153
8154 snapshot_format_menu[SnapshotFormat].flags=D_SELECTED;
8155 return D_O_K;
8156 }
8157
8158
8159 42 void color_layer(RGB *src,RGB *dest,char r,char g,char b,char pos,int32_t from,int32_t to)
8160 {
8161 PALETTE tmp;
8162
8163
2/2
✓ Branch 0 taken 10752 times.
✓ Branch 1 taken 42 times.
10794 for(int32_t i=0; i<256; i++)
8164 {
8165 10752 tmp[i].r=r;
8166 10752 tmp[i].g=g;
8167 10752 tmp[i].b=b;
8168 10752 }
8169
8170 42 fade_interpolate(src,tmp,dest,pos,from,to);
8171 42 }
8172
8173 42 void system_pal()
8174 {
8175 42 is_sys_pal = true;
8176 static PALETTE pal;
8177 42 copy_pal((RGB*)datafile[PAL_GUI].dat, pal);
8178
8179 // set up the grayscale palette
8180
2/2
✓ Branch 0 taken 2688 times.
✓ Branch 1 taken 42 times.
2730 for(int32_t i=128; i<192; i++)
8181 {
8182 2688 pal[i].r = i-128;
8183 2688 pal[i].g = i-128;
8184 2688 pal[i].b = i-128;
8185 2688 }
8186 42 load_colorset(gui_colorset, pal);
8187
8188 42 color_layer(pal, pal, 24,16,16, 28, 128,191);
8189
8190
2/2
✓ Branch 0 taken 5376 times.
✓ Branch 1 taken 42 times.
5418 for(int32_t i=0; i<256; i+=2)
8191 {
8192 5376 int32_t v = (i>>3)+2;
8193 5376 int32_t c = (i>>3)+192;
8194 5376 pal[c] = _RGB(v,v,v+(v>>1));
8195 /*
8196 if(i<240)
8197 {
8198 _allegro_hline(tmp_scr,0,i,319,c);
8199 _allegro_hline(tmp_scr,0,i+1,319,c);
8200 }
8201 */
8202 5376 }
8203
8204 // draw the vertical screen gradient
8205
2/2
✓ Branch 0 taken 10080 times.
✓ Branch 1 taken 42 times.
10122 for(int32_t i=0; i<240; ++i)
8206 {
8207 10080 _allegro_hline(tmp_scr,0,i,319,192+(i*31/239));
8208 10080 }
8209
8210 /*
8211 palrstart= 10*63/255; palrend=166*63/255;
8212 palgstart= 36*63/255; palgend=202*63/255;
8213 palbstart=106*63/255; palbend=240*63/255;
8214 paldivs=32;
8215 for(int32_t i=0; i<paldivs; i++)
8216 {
8217 pal[223-paldivs+1+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8218 pal[223-paldivs+1+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8219 pal[223-paldivs+1+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8220 }
8221 */
8222 42 BITMAP *panorama = create_bitmap_ex(8,256,224);
8223 int32_t ts_height, ts_start;
8224
8225
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
42 if(tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET))
8226 {
8227 clear_to_color(panorama,0);
8228 blit(framebuf,panorama,0,playing_field_offset,0,28,256,224-passive_subscreen_height);
8229 ts_height=224-passive_subscreen_height;
8230 ts_start=28;
8231 }
8232 else
8233 {
8234 42 blit(framebuf,panorama,0,0,0,0,256,224);
8235 42 ts_height=224;
8236 42 ts_start=0;
8237 }
8238
8239 // gray scale the current frame
8240
2/2
✓ Branch 0 taken 9408 times.
✓ Branch 1 taken 42 times.
9450 for(int32_t y=0; y<ts_height; y++)
8241 {
8242
2/2
✓ Branch 0 taken 2408448 times.
✓ Branch 1 taken 9408 times.
2417856 for(int32_t x=0; x<256; x++)
8243 {
8244 2408448 int32_t c = panorama->line[y+ts_start][x];
8245
2/2
✓ Branch 0 taken 2402558 times.
✓ Branch 1 taken 5890 times.
2408448 int32_t gray = zc_min((RAMpal[c].r*42 + RAMpal[c].g*75 + RAMpal[c].b*14) >> 7, 63);
8246 2408448 tmp_scr->line[y+8+ts_start][x+32] = gray+128;
8247 2408448 }
8248 9408 }
8249
8250 42 destroy_bitmap(panorama);
8251
8252 // display everything
8253 42 vsync();
8254 42 hw_palette = &pal;
8255 42 update_hw_pal = true;
8256
8257 // sys_pal = pal;
8258 42 memcpy(sys_pal,pal,sizeof(pal));
8259 42 }
8260
8261 void system_pal2()
8262 {
8263 is_sys_pal = true;
8264 static PALETTE RAMpal2;
8265 copy_pal((RGB*)datafile[PAL_GUI].dat, RAMpal2);
8266
8267 /* Windows 2000 colors
8268 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8269 RAMpal2[dvc(2)] = _RGB( 66*63/255, 65*63/255, 66*63/255);
8270 RAMpal2[dvc(3)] = _RGB(132*63/255, 130*63/255, 132*63/255);
8271 RAMpal2[dvc(4)] = _RGB(212*63/255, 208*63/255, 200*63/255);
8272 RAMpal2[dvc(5)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8273 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8274 RAMpal2[dvc(7)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8275 RAMpal2[dvc(8)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8276
8277 byte palrstart= 10*63/255, palrend=166*63/255,
8278 palgstart= 36*63/255, palgend=202*63/255,
8279 palbstart=106*63/255, palbend=240*63/255,
8280 paldivs=7;
8281 for(int32_t i=0; i<paldivs; i++)
8282 {
8283 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8284 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8285 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8286 }
8287 */
8288
8289 /* Windows 98 colors
8290 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8291 RAMpal2[dvc(2)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8292 RAMpal2[dvc(3)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8293 RAMpal2[dvc(4)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8294 RAMpal2[dvc(5)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8295 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8296 RAMpal2[dvc(7)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8297 RAMpal2[dvc(8)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8298
8299 byte palrstart= 0*63/255, palrend=166*63/255,
8300 palgstart= 0*63/255, palgend=202*63/255,
8301 palbstart=128*63/255, palbend=240*63/255,
8302 paldivs=7;
8303 for(int32_t i=0; i<paldivs; i++)
8304 {
8305 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8306 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8307 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8308 }
8309 */
8310
8311 /* Windows 99 colors
8312 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8313 RAMpal2[dvc(2)] = _RGB( 64*63/255, 64*63/255, 64*63/255);
8314 RAMpal2[dvc(3)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8315 RAMpal2[dvc(4)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8316 RAMpal2[dvc(5)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8317 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8318 RAMpal2[dvc(7)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8319 RAMpal2[dvc(8)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8320 RAMpal2[dvc(9)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8321
8322 byte palrstart= 0*63/255, palrend=166*63/255,
8323 palgstart= 0*63/255, palgend=202*63/255,
8324
8325 palbstart=128*63/255, palbend=240*63/255,
8326 paldivs=6;
8327 for(int32_t i=0; i<paldivs; i++)
8328 {
8329 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8330 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8331 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8332 }
8333 */
8334
8335
8336
8337 RAMpal2[dvc(1)] = _RGB(0*63/255, 0*63/255, 0*63/255);
8338 RAMpal2[dvc(2)] = _RGB(64*63/255, 64*63/255, 64*63/255);
8339 RAMpal2[dvc(3)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8340 RAMpal2[dvc(4)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8341 RAMpal2[dvc(5)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8342 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8343 RAMpal2[dvc(7)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8344 RAMpal2[dvc(8)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8345 RAMpal2[dvc(9)] = _RGB(0*63/255, 0*63/255, 80*63/255);
8346
8347 byte palrstart= 0*63/255, palrend=166*63/255,
8348 palgstart= 0*63/255, palgend=202*63/255,
8349 palbstart=128*63/255, palbend=240*63/255,
8350 paldivs=6;
8351
8352 for(int32_t i=0; i<paldivs; i++)
8353 {
8354 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8355 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8356 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8357 }
8358
8359 gui_bg_color=jwin_pal[jcBOX];
8360 gui_fg_color=jwin_pal[jcBOXFG];
8361
8362 jwin_set_colors(jwin_pal);
8363
8364
8365 // set up the new palette
8366 for(int32_t i=128; i<192; i++)
8367 {
8368 RAMpal2[i].r = i-128;
8369 RAMpal2[i].g = i-128;
8370 RAMpal2[i].b = i-128;
8371 }
8372
8373 /*
8374 for(int32_t i=0; i<64; i++)
8375 {
8376 RAMpal2[128+i] = _RGB(i,i,i)1));
8377 }
8378 */
8379
8380 /*
8381
8382 pal[vc(1)] = _RGB(0x00,0x00,0x14);
8383 pal[vc(4)] = _RGB(0x36,0x36,0x36);
8384 pal[vc(6)] = _RGB(0x10,0x10,0x10);
8385 pal[vc(7)] = _RGB(0x20,0x20,0x20);
8386 pal[vc(9)] = _RGB(0x20,0x20,0x24);
8387 pal[vc(11)] = _RGB(0x30,0x30,0x30);
8388 pal[vc(14)] = _RGB(0x3F,0x38,0x28);
8389
8390 gui_fg_color=vc(14);
8391 gui_bg_color=vc(1);
8392
8393 jwin_set_colors(jwin_pal);
8394 */
8395
8396 // color_layer(RAMpal2, RAMpal2, 24,16,16, 28, 128,191);
8397
8398 // set up the colors for the vertical screen gradient
8399 for(int32_t i=0; i<256; i+=2)
8400 {
8401 int32_t v = (i>>3)+2;
8402 int32_t c = (i>>3)+192;
8403 RAMpal2[c] = _RGB(v,v,v+(v>>1));
8404
8405 /*
8406 if(i<240)
8407 {
8408 _allegro_hline(tmp_scr,0,i,319,c);
8409 _allegro_hline(tmp_scr,0,i+1,319,c);
8410 }
8411 */
8412 }
8413
8414 // hw_palette = &RAMpal;
8415 // update_hw_pal = true;
8416
8417 for(int32_t i=0; i<240; ++i)
8418 {
8419 _allegro_hline(tmp_scr,0,i,319,192+(i*31/239));
8420 }
8421
8422 /*
8423 byte palrstart= 10*63/255, palrend=166*63/255,
8424 palgstart= 36*63/255, palgend=202*63/255,
8425 palbstart=106*63/255, palbend=240*63/255,
8426 paldivs=32;
8427 for(int32_t i=0; i<paldivs; i++)
8428 {
8429 pal[223-paldivs+1+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8430 pal[223-paldivs+1+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8431 pal[223-paldivs+1+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8432 }
8433 */
8434 BITMAP *panorama = create_bitmap_ex(8,256,224);
8435 int32_t ts_height, ts_start;
8436
8437 if(tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET))
8438 {
8439 clear_to_color(panorama,0);
8440 blit(framebuf,panorama,0,playing_field_offset,0,28,256,224-passive_subscreen_height);
8441 ts_height=224-passive_subscreen_height;
8442 ts_start=28;
8443 }
8444 else
8445 {
8446 blit(framebuf,panorama,0,0,0,0,256,224);
8447 ts_height=224;
8448 ts_start=0;
8449 }
8450
8451 // gray scale the current frame
8452 for(int32_t y=0; y<ts_height; y++)
8453 {
8454 for(int32_t x=0; x<256; x++)
8455 {
8456 int32_t c = panorama->line[y+ts_start][x];
8457 int32_t gray = zc_min((RAMpal2[c].r*42 + RAMpal2[c].g*75 + RAMpal2[c].b*14) >> 7, 63);
8458 tmp_scr->line[y+8+ts_start][x+32] = gray+128;
8459 }
8460 }
8461
8462 destroy_bitmap(panorama);
8463
8464 // display everything
8465 vsync();
8466 hw_palette = &RAMpal2;
8467 update_hw_pal = true;
8468
8469 blit(tmp_scr,screen,0,0,scrx,scry,320,240);
8470
8471 // sys_pal = pal;
8472 memcpy(sys_pal,RAMpal2,sizeof(RAMpal2));
8473 }
8474
8475 static uint32_t entered_sys_pal = 0;
8476 14 void enter_sys_pal()
8477 {
8478
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(is_sys_pal)
8479 {
8480 if(entered_sys_pal)
8481 ++entered_sys_pal;
8482 return;
8483 }
8484 14 system_pal();
8485 14 ++entered_sys_pal;
8486 14 }
8487 14 void exit_sys_pal()
8488 {
8489
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(entered_sys_pal)
8490 {
8491
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!--entered_sys_pal)
8492 {
8493 14 game_pal();
8494 14 }
8495 14 }
8496 14 }
8497
8498 void switch_out_callback()
8499 {
8500 if (pause_in_background)
8501 {
8502 callback_switchin = 3;
8503 return;
8504 }
8505
8506 #ifdef _WIN32
8507 if(midi_patch_fix==0 || currmidi==-1)
8508 return;
8509
8510
8511 paused_midi_pos = midi_pos;
8512 zc_stop_midi();
8513 midi_paused=true;
8514 midi_suspended = midissuspHALTED;
8515 #endif
8516 }
8517
8518 void switch_in_callback()
8519 {
8520 if(pause_in_background)
8521 {
8522 return;
8523 }
8524
8525 #ifdef _WIN32
8526 if(midi_patch_fix==0 || currmidi==-1)
8527 return;
8528
8529 else
8530 {
8531 callback_switchin = 1;
8532 midi_suspended = midissuspRESUME;
8533 }
8534 #endif
8535 }
8536
8537 218 void game_pal()
8538 {
8539 218 is_sys_pal = false;
8540 218 entered_sys_pal = 0;
8541 218 clear_to_color(screen,BLACK);
8542 218 hw_palette = &RAMpal;
8543 218 update_hw_pal = true;
8544 218 }
8545
8546 static char bar_str[] = "";
8547
8548 14 void music_pause()
8549 {
8550 //al_pause_duh(tmplayer);
8551 14 zcmusic_pause(zcmusic, ZCM_PAUSE);
8552 14 zc_midi_pause();
8553 14 midi_paused=true;
8554 14 }
8555
8556 void music_resume()
8557 {
8558 //al_resume_duh(tmplayer);
8559 zcmusic_pause(zcmusic, ZCM_RESUME);
8560 zc_midi_resume();
8561 midi_paused=false;
8562 }
8563
8564 4188 void music_stop()
8565 {
8566 //al_stop_duh(tmplayer);
8567 //unload_duh(tmusic);
8568 //tmusic=NULL;
8569 //tmplayer=NULL;
8570 4188 zcmusic_stop(zcmusic);
8571 4188 zcmusic_unload_file(zcmusic);
8572 4188 zc_stop_midi();
8573 4188 midi_paused=false;
8574 4188 currmidi=-1;
8575 4188 }
8576
8577 void System()
8578 {
8579 mouse_down=gui_mouse_b();
8580 music_pause();
8581 pause_all_sfx();
8582 MenuOpen = true;
8583 system_pal();
8584 // FONT *oldfont=font;
8585 // font=tfont;
8586
8587 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
8588 misc_menu[3].flags =(isFullScreen()==1)?D_DISABLED:0;
8589
8590 game_menu[2].flags = getsaveslot() > -1 ? 0 : D_DISABLED;
8591 #if DEVLEVEL > 1
8592 dev_menu[dv_setcheat].flags = Playing ? 0 : D_DISABLED;
8593 #endif
8594 game_menu[3].flags =
8595 misc_menu[5].flags = Playing ? 0 : D_DISABLED;
8596 misc_menu[7].flags = !Playing ? 0 : D_DISABLED;
8597 fixes_menu[0].flags = (midi_patch_fix)?D_SELECTED:0;
8598 clear_keybuf();
8599 show_mouse(screen);
8600
8601 DIALOG_PLAYER *p;
8602
8603 clear_bitmap(menu_bmp);
8604 oldscreen = screen;
8605 screen = menu_bmp;
8606
8607 if(!Playing || (!zcheats.flags && !get_debug() && DEVLEVEL < 2 && !zqtesting_mode))
8608 {
8609 p = init_dialog(system_dlg2,-1);
8610 }
8611 else
8612 {
8613 p = init_dialog(system_dlg,-1);
8614 }
8615
8616 // drop the menu on startup if menu button pressed
8617 if(joybtn(Mbtn)||zc_getrawkey(KEY_ESC))
8618 simulate_keypress(KEY_G << 8);
8619
8620 do
8621 {
8622 if(close_button_quit)
8623 {
8624 close_button_quit = false;
8625 f_Quit(qEXIT);
8626 if(Quit) break;
8627 }
8628 rest(17);
8629
8630 if(mouse_down && !gui_mouse_b())
8631 mouse_down=0;
8632
8633 title_menu[0].flags = (title_version==0) ? D_SELECTED : 0;
8634 title_menu[1].flags = (title_version==1) ? D_SELECTED : 0;
8635 title_menu[2].flags = (title_version==2) ? D_SELECTED : 0;
8636
8637 settings_menu[1].flags = replay_is_replaying() ? D_DISABLED : 0;
8638 settings_menu[5].flags = Throttlefps?D_SELECTED:0;
8639 settings_menu[6].flags = ShowFPS?D_SELECTED:0;
8640 settings_menu[7].flags = TransLayers?D_SELECTED:0;
8641 settings_menu[8].flags = NESquit?D_SELECTED:0;
8642 settings_menu[9].flags = ClickToFreeze?D_SELECTED:0;
8643 settings_menu[10].flags = SaveDragResize?D_SELECTED:0;
8644 settings_menu[11].flags = DragAspect?D_SELECTED:0;
8645 settings_menu[12].flags = SaveWinPos?D_SELECTED:0;
8646 settings_menu[13].flags = volkeys?D_SELECTED:0;
8647 //Epilepsy Prevention
8648 settings_menu[16].flags = (epilepsyFlashReduction) ? D_SELECTED : 0;
8649
8650 name_entry_mode_menu[0].flags = (NameEntryMode==0)?D_SELECTED:0;
8651 name_entry_mode_menu[1].flags = (NameEntryMode==1)?D_SELECTED:0;
8652 name_entry_mode_menu[2].flags = (NameEntryMode==2)?D_SELECTED:0;
8653
8654 misc_menu[12].flags =(zasm_debugger)?D_SELECTED:0;
8655 misc_menu[13].flags =(zscript_debugger)?D_SELECTED:0;
8656 misc_menu[14].flags =(clearConsoleOnLoad)?D_SELECTED:0;
8657
8658 the_player_menu[2].flags = replay_is_replaying() ? D_DISABLED : 0;
8659 cheat_menu[0].flags = 0;
8660 refill_menu[4].flags = get_bit(quest_rules, qr_TRUEARROWS) ? 0 : D_DISABLED;
8661 cheat_menu[1].text = (cheat >= 1) || get_debug() ? bar_str : NULL;
8662 cheat_menu[3].text = (cheat >= 2) || get_debug() ? bar_str : NULL;
8663 cheat_menu[8].text = (cheat >= 3) || get_debug() ? bar_str : NULL;
8664 cheat_menu[10].text = (cheat >= 4) || get_debug() ? bar_str : NULL;
8665 cheat_menu[4].flags = getClock() ? D_SELECTED : 0;
8666 cheat_menu[11].flags = toogam ? D_SELECTED : 0;
8667 cheat_menu[12].flags = ignoreSideview ? D_SELECTED : 0;
8668 cheat_menu[13].flags = gofast ? D_SELECTED : 0;
8669
8670 show_menu[0].flags = show_layer_0 ? D_SELECTED : 0;
8671 show_menu[1].flags = show_layer_1 ? D_SELECTED : 0;
8672 show_menu[2].flags = show_layer_2 ? D_SELECTED : 0;
8673 show_menu[3].flags = show_layer_3 ? D_SELECTED : 0;
8674 show_menu[4].flags = show_layer_4 ? D_SELECTED : 0;
8675 show_menu[5].flags = show_layer_5 ? D_SELECTED : 0;
8676 show_menu[6].flags = show_layer_6 ? D_SELECTED : 0;
8677 show_menu[7].flags = show_layer_over ? D_SELECTED : 0;
8678 show_menu[8].flags = show_layer_push ? D_SELECTED : 0;
8679 show_menu[9].flags = show_sprites ? D_SELECTED : 0;
8680 show_menu[10].flags = show_ffcs ? D_SELECTED : 0;
8681 show_menu[12].flags = show_walkflags ? D_SELECTED : 0;
8682 show_menu[13].flags = show_ff_scripts ? D_SELECTED : 0;
8683 show_menu[14].flags = show_hitboxes ? D_SELECTED : 0;
8684 show_menu[15].flags = show_effectflags ? D_SELECTED : 0;
8685
8686 settings_menu[14].flags = heart_beep ? D_SELECTED : 0;
8687 settings_menu[15].flags = use_save_indicator ? D_SELECTED : 0;
8688
8689 replay_menu[0].text = zc_get_config("zeldadx", "replay_new_saves", false) ?
8690 (char *)"Disable recording new saves" :
8691 (char *)"Enable recording new saves";
8692 replay_menu[1].flags = replay_is_active() ? 0 : D_DISABLED;
8693 replay_menu[1].text = replay_get_mode() == ReplayMode::Record ?
8694 (char *)"Stop recording" :
8695 (char *)"Stop replaying";
8696 replay_menu[5].flags = replay_get_mode() == ReplayMode::Record ? 0 : D_DISABLED;
8697 replay_menu[6].text = replay_is_snapshot_all_frames() ?
8698 (char *)"Disable snapshot all frames" :
8699 (char *)"Enable snapshot all frames";
8700
8701 reset_snapshot_format_menu();
8702 snapshot_format_menu[SnapshotFormat].flags = D_SELECTED;
8703
8704 if(debug_enabled)
8705 {
8706 settings_menu[19].flags = get_debug() ? D_SELECTED : 0;
8707 }
8708
8709 if(gui_mouse_b() && !mouse_down)
8710 break;
8711
8712 // press menu to drop the menu
8713 if(rMbtn())
8714 simulate_keypress(KEY_G << 8);
8715
8716 if(input_idle(true) > after_time())
8717 // run Screeen Saver
8718 {
8719 // Screen saver enabled for now.
8720 clear_keybuf();
8721 scare_mouse();
8722 Matrix(ss_speed, ss_density, 0);
8723 system_pal();
8724 unscare_mouse();
8725 broadcast_dialog_message(MSG_DRAW, 0);
8726 }
8727
8728 update_hw_screen();
8729 }
8730 while(update_dialog(p));
8731
8732 screen = oldscreen;
8733
8734 // font=oldfont;
8735 mouse_down=gui_mouse_b();
8736 shutdown_dialog(p);
8737 show_mouse(NULL);
8738 MenuOpen = false;
8739 if(Quit)
8740 {
8741 kill_sfx();
8742 music_stop();
8743 update_hw_screen();
8744 }
8745 else
8746 {
8747 game_pal();
8748 music_resume();
8749 resume_all_sfx();
8750
8751 if(rc)
8752 ringcolor(false);
8753 }
8754
8755 eat_buttons();
8756
8757 rc=false;
8758 clear_keybuf();
8759 // text_mode(0);
8760 }
8761
8762 28 void fix_dialogs()
8763 {
8764 28 jwin_center_dialog(about_dlg);
8765 28 jwin_center_dialog(gamepad_dlg);
8766 28 jwin_center_dialog(credits_dlg);
8767 28 jwin_center_dialog(gamemode_dlg);
8768 28 jwin_center_dialog(getnum_dlg);
8769 28 jwin_center_dialog(goto_dlg);
8770 28 jwin_center_dialog(keyboard_control_dlg);
8771 28 jwin_center_dialog(midi_dlg);
8772 28 jwin_center_dialog(quest_dlg);
8773 28 jwin_center_dialog(scrsaver_dlg);
8774 28 jwin_center_dialog(sound_dlg);
8775 28 jwin_center_dialog(triforce_dlg);
8776
8777 // digi_dp[1] += scrx;
8778 // digi_dp[2] += scry;
8779 // midi_dp[1] += scrx;
8780 // midi_dp[2] += scry;
8781 // pan_dp[1] += scrx;
8782 // pan_dp[2] += scry;
8783 // emus_dp[1] += scrx;
8784 // emus_dp[2] += scry;
8785 // buf_dp[1] += scrx;
8786 // buf_dp[2] += scry;
8787 // sfx_dp[1] += scrx;
8788 // sfx_dp[2] += scry;
8789 28 }
8790
8791 /*****************************/
8792 /**** Custom Sound System ****/
8793 /*****************************/
8794
8795 1610 INLINE int32_t mixvol(int32_t v1,int32_t v2)
8796 {
8797
3/4
✓ Branch 0 taken 1540 times.
✓ Branch 1 taken 70 times.
✓ Branch 2 taken 1610 times.
✗ Branch 3 not taken.
1610 return (zc_min(v1,255)*zc_min(v2,255)) >> 8;
8798 }
8799
8800 // Run an NSF, or a MIDI if the NSF is missing somehow.
8801 74 bool try_zcmusic(char *filename, int32_t track, int32_t midi)
8802 {
8803 74 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8804
8805 // Found it
8806
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 35 times.
74 if(newzcmusic!=NULL)
8807 {
8808 39 zcmusic_stop(zcmusic);
8809 39 zcmusic_unload_file(zcmusic);
8810 39 zc_stop_midi();
8811
8812 39 zcmusic=newzcmusic;
8813 39 zcmusic_play(zcmusic, emusic_volume);
8814
8815
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39 times.
39 if(track>0)
8816 39 zcmusic_change_track(zcmusic,track);
8817
8818 39 return true;
8819 }
8820
8821 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8822
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 else if(midi>-1000)
8823 jukebox(midi);
8824
8825 35 return false;
8826 74 }
8827
8828 bool try_zcmusic_ex(char *filename, int32_t track, int32_t midi)
8829 {
8830 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8831 // Found it
8832 if(newzcmusic!=NULL)
8833 {
8834 zcmusic_stop(zcmusic);
8835 zcmusic_unload_file(zcmusic);
8836 zc_stop_midi();
8837
8838 zcmusic=newzcmusic;
8839 zcmusic_play(zcmusic, emusic_volume);
8840
8841 if(track>0)
8842 zcmusic_change_track(zcmusic,track);
8843
8844 return true;
8845 }
8846
8847 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8848 else if(midi>-1000)
8849 jukebox(midi);
8850
8851 return false;
8852 }
8853
8854 int32_t get_zcmusicpos()
8855 {
8856 int32_t debugtracething = zcmusic_get_curpos(zcmusic);
8857 return debugtracething;
8858 return 0;
8859 }
8860
8861 void set_zcmusicpos(int32_t position)
8862 {
8863 zcmusic_set_curpos(zcmusic, position);
8864 }
8865
8866 void set_zcmusicspeed(int32_t speed)
8867 {
8868 int32_t newspeed = vbound(speed, 0, 10000);
8869 zcmusic_set_speed(zcmusic, newspeed);
8870 }
8871
8872 791 void jukebox(int32_t index,int32_t loop)
8873 {
8874 791 music_stop();
8875
8876
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 791 times.
791 if(index<0) index=MAXMIDIS-1;
8877
8878
1/2
✓ Branch 0 taken 791 times.
✗ Branch 1 not taken.
791 if(index>=MAXMIDIS) index=0;
8879
8880 791 music_stop();
8881
8882 // Allegro's DIGMID driver (the one normally used on on Linux) gets
8883 // stuck notes when a song stops. This fixes it.
8884
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 791 times.
791 if(strcmp(midi_driver->name, "DIGMID")==0)
8885 zc_set_volume(0, 0);
8886
8887 791 zc_set_volume(-1, mixvol(tunes[index].volume,midi_volume>>1));
8888 791 zc_play_midi((MIDI*)tunes[index].data,loop);
8889
8890
2/2
✓ Branch 0 taken 582 times.
✓ Branch 1 taken 209 times.
791 if(tunes[index].start>0)
8891 209 zc_midi_seek(tunes[index].start);
8892
8893 791 midi_loop_start = tunes[index].loop_start;
8894 791 midi_loop_end = tunes[index].loop_end;
8895
8896 791 currmidi=index;
8897 791 master_volume(digi_volume,midi_volume);
8898 791 midi_paused=false;
8899 791 }
8900
8901 5392 void jukebox(int32_t index)
8902 {
8903
1/2
✓ Branch 0 taken 5392 times.
✗ Branch 1 not taken.
5392 if(index<0) index=MAXMIDIS-1;
8904
8905
1/2
✓ Branch 0 taken 5392 times.
✗ Branch 1 not taken.
5392 if(index>=MAXMIDIS) index=0;
8906
8907 // do nothing if it's already playing
8908
3/4
✓ Branch 0 taken 4601 times.
✓ Branch 1 taken 791 times.
✓ Branch 2 taken 4601 times.
✗ Branch 3 not taken.
5392 if(index==currmidi && midi_pos>=0)
8909 {
8910 4601 midi_paused=false;
8911 4601 return;
8912 }
8913
8914 791 jukebox(index,tunes[index].loop);
8915 5392 }
8916
8917 6631 void play_DmapMusic()
8918 {
8919 static char tfile[2048];
8920 static int32_t ttrack=0;
8921 6631 bool domidi=false;
8922
8923
2/2
✓ Branch 0 taken 1330 times.
✓ Branch 1 taken 5301 times.
6631 if(DMaps[currdmap].tmusic[0]!=0)
8924 {
8925
3/4
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 945 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 385 times.
1715 if(zcmusic==NULL ||
8926
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 strcmp(zcmusic->filename,DMaps[currdmap].tmusic)!=0 ||
8927
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 (zcmusic->type==ZCMF_GME && zcmusic->track != DMaps[currdmap].tmusictrack))
8928 {
8929
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 945 times.
945 if(zcmusic != NULL)
8930 {
8931 zcmusic_stop(zcmusic);
8932 zcmusic_unload_file(zcmusic);
8933 zcmusic = NULL;
8934 }
8935
8936 945 zcmusic = zcmusic_load_for_quest(DMaps[currdmap].tmusic, qstpath);
8937
8938
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 859 times.
945 if(zcmusic!=NULL)
8939 {
8940 86 zc_stop_midi();
8941 86 strcpy(tfile,DMaps[currdmap].tmusic);
8942 86 zcmusic_play(zcmusic, emusic_volume);
8943 86 int32_t temptracks=0;
8944 86 temptracks=zcmusic_get_tracks(zcmusic);
8945
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 86 times.
86 temptracks=(temptracks<2)?1:temptracks;
8946 86 ttrack = vbound(DMaps[currdmap].tmusictrack,0,temptracks-1);
8947 86 zcmusic_change_track(zcmusic,ttrack);
8948 86 }
8949 else
8950 {
8951 859 tfile[0] = 0;
8952 859 domidi=true;
8953 }
8954 945 }
8955 1330 }
8956 else
8957 {
8958 5301 domidi=true;
8959 }
8960
8961
2/2
✓ Branch 0 taken 471 times.
✓ Branch 1 taken 6160 times.
6631 if(domidi)
8962 {
8963 6160 int32_t m=DMaps[currdmap].midi;
8964
8965
3/4
✓ Branch 0 taken 6045 times.
✓ Branch 1 taken 105 times.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
6160 switch(m)
8966 {
8967 case 1:
8968 105 jukebox(ZC_MIDI_OVERWORLD);
8969 105 break;
8970
8971 case 2:
8972 10 jukebox(ZC_MIDI_DUNGEON);
8973 10 break;
8974
8975 case 3:
8976 jukebox(ZC_MIDI_LEVEL9);
8977 break;
8978
8979 default:
8980
3/4
✓ Branch 0 taken 5136 times.
✓ Branch 1 taken 909 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5136 times.
6045 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8981 5136 jukebox(m+MIDIOFFSET_DMAP);
8982 else
8983 909 music_stop();
8984 6045 }
8985 6160 }
8986 6631 }
8987
8988 6668 void playLevelMusic()
8989 {
8990 6668 int32_t m=tmpscr->screen_midi;
8991
8992
3/6
✓ Branch 0 taken 6615 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 41 times.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
6668 switch(m)
8993 {
8994 case -2:
8995 12 music_stop();
8996 12 break;
8997
8998 case -1:
8999 6615 play_DmapMusic();
9000 6615 break;
9001
9002 case 1:
9003 jukebox(ZC_MIDI_OVERWORLD);
9004 break;
9005
9006 case 2:
9007 jukebox(ZC_MIDI_DUNGEON);
9008 break;
9009
9010 case 3:
9011 jukebox(ZC_MIDI_LEVEL9);
9012 break;
9013
9014 default:
9015
2/4
✓ Branch 0 taken 41 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 41 times.
✗ Branch 3 not taken.
41 if(m>=4 && m<4+MAXCUSTOMMIDIS)
9016 41 jukebox(m+MIDIOFFSET_MAPSCR);
9017 else
9018 music_stop();
9019 41 }
9020 6668 }
9021
9022 819 void master_volume(int32_t dv,int32_t mv)
9023 {
9024
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 819 times.
✓ Branch 2 taken 819 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 819 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 819 times.
✗ Branch 7 not taken.
819 if(dv>=0) digi_volume=zc_max(zc_min(dv,255),0);
9025
9026
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 819 times.
✓ Branch 2 taken 819 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 819 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 819 times.
✗ Branch 7 not taken.
819 if(mv>=0) midi_volume=zc_max(zc_min(mv,255),0);
9027
9028
6/6
✓ Branch 0 taken 790 times.
✓ Branch 1 taken 29 times.
✓ Branch 2 taken 818 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 789 times.
✓ Branch 5 taken 29 times.
819 int32_t i = zc_min(zc_max(currmidi,0),MAXMIDIS-1);
9029 819 zc_set_volume(digi_volume,mixvol(tunes[i].volume,midi_volume));
9030 819 }
9031
9032 /*****************/
9033 /***** SFX *****/
9034 /*****************/
9035
9036 // array of voices, one for each sfx sample in the data file
9037 // 0+ = voice #
9038 // -1 = voice not allocated
9039 28 void Z_init_sound()
9040 {
9041
2/2
✓ Branch 0 taken 7168 times.
✓ Branch 1 taken 28 times.
7196 for(int32_t i=0; i<WAV_COUNT; i++)
9042 7168 sfx_voice[i]=-1;
9043
9044
2/2
✓ Branch 0 taken 196 times.
✓ Branch 1 taken 28 times.
224 for(int32_t i=0; i<ZC_MIDI_COUNT; i++)
9045 196 tunes[i].data = (MIDI*)mididata[i].dat;
9046
9047
2/2
✓ Branch 0 taken 7056 times.
✓ Branch 1 taken 28 times.
7084 for(int32_t j=0; j<MAXCUSTOMMIDIS; j++)
9048 7056 tunes[ZC_MIDI_COUNT+j].data=NULL;
9049
9050 28 master_volume(digi_volume,midi_volume);
9051 28 }
9052
9053 // returns number of voices currently allocated
9054 int32_t sfx_count()
9055 {
9056 int32_t c=0;
9057
9058 for(int32_t i=0; i<WAV_COUNT; i++)
9059 if(sfx_voice[i]!=-1)
9060 ++c;
9061
9062 return c;
9063 }
9064
9065 // clean up finished samples
9066 4794176 void sfx_cleanup()
9067 {
9068
2/2
✓ Branch 0 taken 1227309056 times.
✓ Branch 1 taken 4794176 times.
1232103232 for(int32_t i=0; i<WAV_COUNT; i++)
9069
3/4
✓ Branch 0 taken 450467 times.
✓ Branch 1 taken 1226858589 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 450467 times.
1227759523 if(sfx_voice[i]!=-1 && voice_get_position(sfx_voice[i])<0)
9070 {
9071 450467 deallocate_voice(sfx_voice[i]);
9072 450467 sfx_voice[i]=-1;
9073 450467 }
9074 4794176 }
9075
9076 // allocates a voice for the sample "wav_index" (index into zelda.dat)
9077 // if a voice is already allocated (and/or playing), then it just returns true
9078 // Returns true: voice is allocated
9079 // false: unsuccessful
9080 683368 bool sfx_init(int32_t index)
9081 {
9082 // check index
9083
3/4
✓ Branch 0 taken 502869 times.
✓ Branch 1 taken 180499 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 502869 times.
683368 if(index<=0 || index>=WAV_COUNT)
9084 180499 return false;
9085
9086
2/2
✓ Branch 0 taken 52382 times.
✓ Branch 1 taken 450487 times.
502869 if(sfx_voice[index]==-1)
9087 {
9088
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 450487 times.
450487 if(sfxdat)
9089 {
9090 if(index<Z35)
9091 {
9092 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[index].dat);
9093 }
9094 else
9095 {
9096 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[Z35].dat);
9097 }
9098 }
9099 else
9100 {
9101 450487 sfx_voice[index]=allocate_voice(&customsfxdata[index]);
9102 }
9103
9104 450487 voice_set_volume(sfx_voice[index], sfx_volume);
9105 450487 }
9106
9107 502869 return sfx_voice[index] != -1;
9108 683368 }
9109
9110 // plays an sfx sample
9111 587877 void sfx(int32_t index,int32_t pan,bool loop, bool restart)
9112 {
9113
2/2
✓ Branch 0 taken 440900 times.
✓ Branch 1 taken 146977 times.
587877 if(!sfx_init(index))
9114 146977 return;
9115
9116 440900 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
9117 440900 voice_set_pan(sfx_voice[index],pan);
9118
9119 440900 int32_t pos = voice_get_position(sfx_voice[index]);
9120
9121
2/2
✓ Branch 0 taken 261051 times.
✓ Branch 1 taken 179849 times.
440900 if(restart) voice_set_position(sfx_voice[index],0);
9122
9123
1/2
✓ Branch 0 taken 440900 times.
✗ Branch 1 not taken.
440900 if(pos<=0)
9124 440900 voice_start(sfx_voice[index]);
9125 587877 }
9126
9127 // true if sfx is allocated
9128 21672 bool sfx_allocated(int32_t index)
9129 {
9130
2/4
✓ Branch 0 taken 21672 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 21672 times.
21672 return (index>0 && index<WAV_COUNT && sfx_voice[index]!=-1);
9131 }
9132
9133 // start it (in loop mode) if it's not already playing,
9134 // otherwise adjust it to play in loop mode -DD
9135 95491 void cont_sfx(int32_t index)
9136 {
9137
2/2
✓ Branch 0 taken 33522 times.
✓ Branch 1 taken 61969 times.
95491 if(!sfx_init(index))
9138 {
9139 33522 return;
9140 }
9141
9142
1/2
✓ Branch 0 taken 61969 times.
✗ Branch 1 not taken.
61969 if(voice_get_position(sfx_voice[index])<=0)
9143 {
9144 61969 voice_set_position(sfx_voice[index],0);
9145 61969 voice_set_playmode(sfx_voice[index],PLAYMODE_LOOP);
9146 61969 voice_start(sfx_voice[index]);
9147 61969 }
9148 else
9149 {
9150 adjust_sfx(index, 128, true);
9151 }
9152 95491 }
9153
9154 // adjust parameters while playing
9155 2756 void adjust_sfx(int32_t index,int32_t pan,bool loop)
9156 {
9157
5/6
✓ Branch 0 taken 1590 times.
✓ Branch 1 taken 1166 times.
✓ Branch 2 taken 1590 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✓ Branch 5 taken 1578 times.
2756 if(index<=0 || index>=WAV_COUNT || sfx_voice[index]==-1)
9158 2744 return;
9159
9160 12 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
9161 12 voice_set_pan(sfx_voice[index],pan);
9162 2756 }
9163
9164 // pauses a voice
9165 1037 void pause_sfx(int32_t index)
9166 {
9167
3/6
✓ Branch 0 taken 1037 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1037 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1037 times.
1037 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
9168 voice_stop(sfx_voice[index]);
9169 1037 }
9170
9171 // resumes a voice
9172 484 void resume_sfx(int32_t index)
9173 {
9174
3/6
✓ Branch 0 taken 484 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 484 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 484 times.
484 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
9175 voice_start(sfx_voice[index]);
9176 484 }
9177
9178 // pauses all active voices
9179 113 void pause_all_sfx()
9180 {
9181
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 113 times.
29041 for(int32_t i=0; i<WAV_COUNT; i++)
9182
2/2
✓ Branch 0 taken 28926 times.
✓ Branch 1 taken 2 times.
28930 if(sfx_voice[i]!=-1)
9183 2 voice_stop(sfx_voice[i]);
9184 113 }
9185
9186 // resumes all paused voices
9187 99 void resume_all_sfx()
9188 {
9189
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<WAV_COUNT; i++)
9190
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(sfx_voice[i]!=-1)
9191 voice_start(sfx_voice[i]);
9192 99 }
9193
9194 // stops an sfx and deallocates the voice
9195 3803780 void stop_sfx(int32_t index)
9196 {
9197
3/4
✓ Branch 0 taken 3712139 times.
✓ Branch 1 taken 91641 times.
✓ Branch 2 taken 3712139 times.
✗ Branch 3 not taken.
3803780 if(index<=0 || index>=WAV_COUNT)
9198 91641 return;
9199
9200
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3712126 times.
3712139 if(sfx_voice[index]!=-1)
9201 {
9202 13 deallocate_voice(sfx_voice[index]);
9203 13 sfx_voice[index]=-1;
9204 13 }
9205 3803780 }
9206
9207 // Stops SFX played by Hero's item of the given family
9208 131093 void stop_item_sfx(int32_t family)
9209 {
9210 131093 int32_t id=current_item_id(family);
9211
9212
2/2
✓ Branch 0 taken 130827 times.
✓ Branch 1 taken 266 times.
131093 if(id<0)
9213 130827 return;
9214
9215 266 stop_sfx(itemsbuf[id].usesound);
9216 131093 }
9217
9218 1400 void kill_sfx()
9219 {
9220
2/2
✓ Branch 0 taken 358400 times.
✓ Branch 1 taken 1400 times.
359800 for(int32_t i=0; i<WAV_COUNT; i++)
9221
2/2
✓ Branch 0 taken 358393 times.
✓ Branch 1 taken 7 times.
358407 if(sfx_voice[i]!=-1)
9222 {
9223 7 deallocate_voice(sfx_voice[i]);
9224 7 sfx_voice[i]=-1;
9225 7 }
9226 1400 }
9227
9228 372465 int32_t pan(int32_t x)
9229 {
9230
1/4
✓ Branch 0 taken 372465 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
372465 switch(pan_style)
9231 {
9232 case 0:
9233 return 128;
9234
9235 case 1:
9236 372465 return vbound((x>>1)+68,0,255);
9237
9238 case 2:
9239 return vbound(((x*3)>>2)+36,0,255);
9240 }
9241
9242 return vbound(x,0,255);
9243 372465 }
9244
9245 /*******************************/
9246 /******* Input Handlers ********/
9247 /*******************************/
9248
9249 11390682 bool joybtn(int32_t b)
9250 {
9251
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11390682 times.
11390682 if(b == 0)
9252 return false;
9253
9254 11390682 return joy[joystick_index].button[b-1].b !=0;
9255 11390682 }
9256
9257 const char* joybtn_name(int32_t b)
9258 {
9259 if(b == 0)
9260 return "";
9261
9262 return joy[joystick_index].button[b-1].name;
9263 }
9264
9265 int32_t next_press_key()
9266 {
9267 return readkey()>>8;
9268 }
9269
9270 int32_t next_press_btn()
9271 {
9272 clear_keybuf();
9273 /*bool b[joy[joystick_index].num_buttons+1];
9274
9275 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9276 b[i]=joybtn(i);*/
9277
9278 //first, we need to wait until they're pressing no buttons
9279 for(;;)
9280 {
9281 if(keypressed())
9282 {
9283 switch(readkey()>>8)
9284 {
9285 case KEY_ESC:
9286 return -1;
9287
9288 case KEY_SPACE:
9289 return 0;
9290 }
9291 }
9292
9293 poll_joystick();
9294 bool done = true;
9295
9296 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9297 {
9298 if(joybtn(i)) done = false;
9299 }
9300
9301 if(done) break;
9302 rest(1);
9303 }
9304
9305 //now, we need to wait for them to press any button
9306 for(;;)
9307 {
9308 if(keypressed())
9309 {
9310 switch(readkey()>>8)
9311 {
9312 case KEY_ESC:
9313 return -1;
9314
9315 case KEY_SPACE:
9316 return 0;
9317 }
9318 }
9319
9320 poll_joystick();
9321
9322 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9323 {
9324 if(joybtn(i)) return i;
9325 }
9326 rest(1);
9327 }
9328 }
9329
9330 98412891 static bool rButton(bool &btn, bool &flag, bool* rawbtn = nullptr)
9331 {
9332
2/2
✓ Branch 0 taken 94798656 times.
✓ Branch 1 taken 3614235 times.
98412891 bool ret = btn && !flag;
9333
2/2
✓ Branch 0 taken 91493195 times.
✓ Branch 1 taken 6919696 times.
98412891 flag = rawbtn ? *rawbtn : btn;
9334
9335 98412891 return ret;
9336 }
9337 10039 static bool rButtonPeek(bool btn, bool flag)
9338 {
9339
2/2
✓ Branch 0 taken 9794 times.
✓ Branch 1 taken 245 times.
10039 if(!btn)
9340 {
9341 9794 return false;
9342 }
9343
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 193 times.
245 else if(!flag)
9344 {
9345 52 return true;
9346 }
9347
9348 193 return false;
9349 10039 }
9350
9351 // Updated only by keyboard/gamepad.
9352 // If in replay mode, this is set directly by the replay system.
9353 // This should never be read from directly - use control_state instead.
9354 bool raw_control_state[ZC_CONTROL_STATES];
9355
9356 // Every call to load_control_state (pretty much every frame) resets this to be equal to raw_control_state.
9357 // This state can drift from raw_control_state if button states are "eaten" or overriden by a script. But that only
9358 // lasts until the next call to load_control_state.
9359 bool control_state[ZC_CONTROL_STATES];
9360 bool disable_control[ZC_CONTROL_STATES];
9361 bool drunk_toggle_state[11];
9362 bool disabledKeys[127];
9363 bool KeyInput[127];
9364 bool KeyPress[127];
9365
9366 bool key_current_frame[127];
9367 bool key_previous_frame[127];
9368
9369 static bool key_system[127];
9370 static bool key_system_previous[127];
9371 static bool key_system_press[127];
9372
9373 bool button_press[ZC_CONTROL_STATES];
9374 bool button_hold[ZC_CONTROL_STATES];
9375
9376 #define STICK_1_X joy[joystick_index].stick[js_stick_1_x_stick].axis[js_stick_1_x_axis]
9377 #define STICK_1_Y joy[joystick_index].stick[js_stick_1_y_stick].axis[js_stick_1_y_axis]
9378 #define STICK_2_X joy[joystick_index].stick[js_stick_2_x_stick].axis[js_stick_2_x_axis]
9379 #define STICK_2_Y joy[joystick_index].stick[js_stick_2_y_stick].axis[js_stick_2_y_axis]
9380 #define STICK_PRECISION 56 //define your own sensitivity
9381
9382 3988770 void load_control_state()
9383 {
9384 3988770 load_control_called_this_frame = true;
9385
9386
3/4
✓ Branch 0 taken 1117569 times.
✓ Branch 1 taken 2871201 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1117569 times.
3988770 if (replay_get_version() >= 8 && replay_get_version() < 11)
9387 {
9388
2/2
✓ Branch 0 taken 20116242 times.
✓ Branch 1 taken 1117569 times.
21233811 for (int i = 0; i < ZC_CONTROL_STATES; i++)
9389 20116242 down_control_states[i] = raw_control_state[i];
9390 1117569 }
9391
9392
1/2
✓ Branch 0 taken 3988770 times.
✗ Branch 1 not taken.
3988770 if (!replay_is_replaying())
9393 {
9394 raw_control_state[0]=zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset < -STICK_PRECISION : joybtn(DUbtn));
9395 raw_control_state[1]=zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn));
9396 raw_control_state[2]=zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn));
9397 raw_control_state[3]=zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn));
9398 raw_control_state[4]=zc_getrawkey(Akey, true)||joybtn(Abtn);
9399 raw_control_state[5]=zc_getrawkey(Bkey, true)||joybtn(Bbtn);
9400 raw_control_state[6]=zc_getrawkey(Skey, true)||joybtn(Sbtn);
9401 raw_control_state[7]=zc_getrawkey(Lkey, true)||joybtn(Lbtn);
9402 raw_control_state[8]=zc_getrawkey(Rkey, true)||joybtn(Rbtn);
9403 raw_control_state[9]=zc_getrawkey(Pkey, true)||joybtn(Pbtn);
9404 raw_control_state[10]=zc_getrawkey(Exkey1, true)||joybtn(Exbtn1);
9405 raw_control_state[11]=zc_getrawkey(Exkey2, true)||joybtn(Exbtn2);
9406 raw_control_state[12]=zc_getrawkey(Exkey3, true)||joybtn(Exbtn3);
9407 raw_control_state[13]=zc_getrawkey(Exkey4, true)||joybtn(Exbtn4);
9408
9409 if(num_joysticks != 0)
9410 {
9411 raw_control_state[14] = STICK_2_Y.pos - js_stick_2_y_offset < -STICK_PRECISION;
9412 raw_control_state[15] = STICK_2_Y.pos - js_stick_2_y_offset > STICK_PRECISION;
9413 raw_control_state[16] = STICK_2_X.pos - js_stick_2_x_offset < -STICK_PRECISION;
9414 raw_control_state[17] = STICK_2_X.pos - js_stick_2_x_offset > STICK_PRECISION;
9415 // zprint2("Detected %d joysticks... %d%d%d%d\n", num_joysticks, raw_control_state[14]?1:0, raw_control_state[15]?1:0, raw_control_state[16]?1:0, raw_control_state[17]?1:0);
9416 }
9417 else
9418 {
9419 raw_control_state[14] = false;
9420 raw_control_state[15] = false;
9421 raw_control_state[16] = false;
9422 raw_control_state[17] = false;
9423 // zprint2("Detected 0 joysticks... clearing inputaxis values.\n");
9424 }
9425 }
9426
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3988767 times.
3988770 if (replay_is_active())
9427 {
9428
2/2
✓ Branch 0 taken 1015215 times.
✓ Branch 1 taken 2973552 times.
3988767 if (replay_get_version() < 3)
9429 1015215 replay_poll();
9430
3/4
✓ Branch 0 taken 2973552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1212177 times.
✓ Branch 3 taken 1761375 times.
2973552 else if (replay_is_replaying() && replay_get_version() < 6)
9431 1761375 replay_peek_input();
9432
4/6
✓ Branch 0 taken 1212177 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1117569 times.
✓ Branch 3 taken 94608 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1117569 times.
1212177 else if (replay_is_replaying() && replay_get_version() >= 8 && replay_get_version() < 11)
9433 1117569 replay_peek_input();
9434
2/2
✓ Branch 0 taken 2871301 times.
✓ Branch 1 taken 1117466 times.
3988767 if (replay_get_version() == 8)
9435 1117466 update_keys();
9436 3988767 }
9437
9438 // Some test replay files were made before a serious input bug was fixed, so instead
9439 // of re-doing them or tossing them out, just check for that zplay version.
9440
3/4
✓ Branch 0 taken 3988764 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121900 times.
✓ Branch 3 taken 3866864 times.
3988770 bool botched_input = replay_is_active() && replay_get_version() != 1 && replay_get_version() < 8;
9441
2/2
✓ Branch 0 taken 71797752 times.
✓ Branch 1 taken 3988764 times.
75786516 for (int i = 0; i < ZC_CONTROL_STATES; i++)
9442 {
9443 71797752 control_state[i] = raw_control_state[i];
9444
4/4
✓ Branch 0 taken 49487310 times.
✓ Branch 1 taken 22310442 times.
✓ Branch 2 taken 2410168 times.
✓ Branch 3 taken 47077142 times.
71797752 if (botched_input && !control_state[i])
9445 47077142 down_control_states[i] = false;
9446 71797752 }
9447
9448 3988764 button_press[0]=rButton(control_state[0],button_hold[0]);
9449 3988764 button_press[1]=rButton(control_state[1],button_hold[1]);
9450 3988764 button_press[2]=rButton(control_state[2],button_hold[2]);
9451 3988764 button_press[3]=rButton(control_state[3],button_hold[3]);
9452 3988764 button_press[4]=rButton(control_state[4],button_hold[4]);
9453 3988764 button_press[5]=rButton(control_state[5],button_hold[5]);
9454 3988764 button_press[6]=rButton(control_state[6],button_hold[6]);
9455 3988764 button_press[7]=rButton(control_state[7],button_hold[7]);
9456 3988764 button_press[8]=rButton(control_state[8],button_hold[8]);
9457 3988764 button_press[9]=rButton(control_state[9],button_hold[9]);
9458 3988764 button_press[10]=rButton(control_state[10],button_hold[10]);
9459 3988764 button_press[11]=rButton(control_state[11],button_hold[11]);
9460 3988764 button_press[12]=rButton(control_state[12],button_hold[12]);
9461 3988764 button_press[13]=rButton(control_state[13],button_hold[13]);
9462 3988764 button_press[14]=rButton(control_state[14],button_hold[14]);
9463 3988764 button_press[15]=rButton(control_state[15],button_hold[15]);
9464 3988764 button_press[16]=rButton(control_state[16],button_hold[16]);
9465 3988764 button_press[17]=rButton(control_state[17],button_hold[17]);
9466 3988764 }
9467
9468 // Returns true if any game key is pressed. This is needed because keypressed()
9469 // doesn't detect modifier keys and control_state[] can be modified by scripts.
9470 20700760 bool zc_key_pressed()
9471 //may also need to use zc_getrawkey
9472 {
9473
7/10
✓ Branch 0 taken 16736822 times.
✓ Branch 1 taken 3963938 times.
✓ Branch 2 taken 3963938 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3963938 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3371702 times.
✓ Branch 7 taken 3371702 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1110232 times.
21810992 if((zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset< -STICK_PRECISION : joybtn(DUbtn))) ||
9474
4/6
✓ Branch 0 taken 3371702 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3371702 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2530856 times.
✓ Branch 5 taken 2530856 times.
3371702 (zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn))) ||
9475
4/6
✓ Branch 0 taken 2530856 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2530856 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1600167 times.
✓ Branch 5 taken 1600167 times.
2530856 (zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn))) ||
9476
4/6
✓ Branch 0 taken 1600167 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1600167 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1284025 times.
✓ Branch 5 taken 1284025 times.
1600167 (zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn))) ||
9477
1/2
✓ Branch 0 taken 1284025 times.
✗ Branch 1 not taken.
1284025 (zc_getrawkey(Akey, true)||joybtn(Abtn)) ||
9478
3/4
✓ Branch 0 taken 1193369 times.
✓ Branch 1 taken 90656 times.
✓ Branch 2 taken 1193369 times.
✗ Branch 3 not taken.
1284025 (zc_getrawkey(Bkey, true)||joybtn(Bbtn)) ||
9479
3/4
✓ Branch 0 taken 1129900 times.
✓ Branch 1 taken 63469 times.
✓ Branch 2 taken 1129900 times.
✗ Branch 3 not taken.
1193369 (zc_getrawkey(Skey, true)||joybtn(Sbtn)) ||
9480
3/4
✓ Branch 0 taken 1119117 times.
✓ Branch 1 taken 10783 times.
✓ Branch 2 taken 1119117 times.
✗ Branch 3 not taken.
1129900 (zc_getrawkey(Lkey, true)||joybtn(Lbtn)) ||
9481
3/4
✓ Branch 0 taken 1111460 times.
✓ Branch 1 taken 7657 times.
✓ Branch 2 taken 1111460 times.
✗ Branch 3 not taken.
1119117 (zc_getrawkey(Rkey, true)||joybtn(Rbtn)) ||
9482
3/4
✓ Branch 0 taken 1111060 times.
✓ Branch 1 taken 400 times.
✓ Branch 2 taken 1111060 times.
✗ Branch 3 not taken.
1111460 (zc_getrawkey(Pkey, true)||joybtn(Pbtn)) ||
9483
3/4
✓ Branch 0 taken 1111017 times.
✓ Branch 1 taken 43 times.
✓ Branch 2 taken 1111017 times.
✗ Branch 3 not taken.
1111060 (zc_getrawkey(Exkey1, true)||joybtn(Exbtn1)) ||
9484
3/4
✓ Branch 0 taken 1110251 times.
✓ Branch 1 taken 766 times.
✓ Branch 2 taken 1110251 times.
✗ Branch 3 not taken.
1111017 (zc_getrawkey(Exkey2, true)||joybtn(Exbtn2)) ||
9485
2/4
✓ Branch 0 taken 1110251 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1110251 times.
✗ Branch 3 not taken.
1110251 (zc_getrawkey(Exkey3, true)||joybtn(Exbtn3)) ||
9486
2/2
✓ Branch 0 taken 1110232 times.
✓ Branch 1 taken 19 times.
1110251 (zc_getrawkey(Exkey4, true)||joybtn(Exbtn4))) // Skipping joystick axes
9487 37164028 return true;
9488
9489 1110232 return false;
9490 4800616 }
9491
9492 79197036 bool getInput(int32_t btn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9493 {
9494 79197036 bool ret = false, drunkstate = false, rawret = false;
9495 79197036 bool* flag = &down_control_states[btn];
9496
2/7
✓ Branch 0 taken 74391456 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 4805580 times.
79197036 switch(btn)
9497 {
9498 case btnF12:
9499 ret = zc_getkey(KEY_F12, ignoreDisable);
9500 rawret = zc_getrawkey(KEY_F12, ignoreDisable);
9501 eatEntirely = false;
9502 break;
9503 case btnF11:
9504 ret = zc_getkey(KEY_F11, ignoreDisable);
9505 rawret = zc_getrawkey(KEY_F11, ignoreDisable);
9506 eatEntirely = false;
9507 break;
9508 case btnF5:
9509 ret = zc_getkey(KEY_F5, ignoreDisable);
9510 rawret = zc_getrawkey(KEY_F5, ignoreDisable);
9511 eatEntirely = false;
9512 break;
9513 case btnQ:
9514 ret = zc_getkey(KEY_Q, ignoreDisable);
9515 rawret = zc_getrawkey(KEY_Q, ignoreDisable);
9516 eatEntirely = false;
9517 break;
9518 case btnI:
9519 ret = zc_getkey(KEY_I, ignoreDisable);
9520 rawret = zc_getrawkey(KEY_I, ignoreDisable);
9521 eatEntirely = false;
9522 break;
9523 case btnM:
9524
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4805580 times.
4805580 if(FFCore.kb_typing_mode) return false;
9525 4805580 rawret = ret = zc_getrawkey(KEY_ESC, ignoreDisable);
9526 4805580 eatEntirely = false;
9527 4805580 break;
9528 default: //control_state[] index
9529
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74391456 times.
74391456 if(FFCore.kb_typing_mode) return false;
9530
5/6
✓ Branch 0 taken 74229094 times.
✓ Branch 1 taken 162362 times.
✓ Branch 2 taken 2164291 times.
✓ Branch 3 taken 72064803 times.
✓ Branch 4 taken 2164291 times.
✗ Branch 5 not taken.
74391456 if(!ignoreDisable && get_bit(quest_rules, qr_FIXDRUNKINPUTS) && disable_control[btn]) drunk = false;
9531
2/2
✓ Branch 0 taken 4027290 times.
✓ Branch 1 taken 70364166 times.
74391456 else if(btn<11) drunkstate = drunk_toggle_state[btn];
9532
4/4
✓ Branch 0 taken 66553487 times.
✓ Branch 1 taken 7837969 times.
✓ Branch 2 taken 1187 times.
✓ Branch 3 taken 7836782 times.
82229425 ret = control_state[btn] && (ignoreDisable || !disable_control[btn]);
9533 74391456 rawret = raw_control_state[btn];
9534 74391456 }
9535
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79197036 times.
79197036 assert(flag);
9536
2/2
✓ Branch 0 taken 52571858 times.
✓ Branch 1 taken 26625178 times.
79197036 if(press)
9537 {
9538
2/2
✓ Branch 0 taken 10039 times.
✓ Branch 1 taken 26615139 times.
26625178 if(peek)
9539 10039 ret = rButtonPeek(ret, *flag);
9540
3/4
✓ Branch 0 taken 26615139 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6919696 times.
✓ Branch 3 taken 19695443 times.
26615139 else if (replay_is_active() && replay_get_version() < 8) ret = rButton(ret, *flag);
9541 6919696 else ret = rButton(ret, *flag, &rawret);
9542 26625178 }
9543
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 79197036 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
79197036 if(eatEntirely && ret) control_state[btn] = false;
9544
3/4
✓ Branch 0 taken 59778423 times.
✓ Branch 1 taken 19418613 times.
✓ Branch 2 taken 59778423 times.
✗ Branch 3 not taken.
79197036 if(drunk && drunkstate) ret = !ret;
9545 79197036 return ret;
9546 79197036 }
9547
9548 397790 byte getIntBtnInput(byte intbtn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9549 {
9550 397790 byte ret = 0;
9551
2/2
✓ Branch 0 taken 385761 times.
✓ Branch 1 taken 12029 times.
397790 if(intbtn & INT_BTN_A) ret |= getInput(btnA, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_A : 0;
9552
2/2
✓ Branch 0 taken 397228 times.
✓ Branch 1 taken 562 times.
397790 if(intbtn & INT_BTN_B) ret |= getInput(btnB, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_B : 0;
9553
2/2
✓ Branch 0 taken 397353 times.
✓ Branch 1 taken 437 times.
397790 if(intbtn & INT_BTN_L) ret |= getInput(btnL, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_L : 0;
9554
2/2
✓ Branch 0 taken 397353 times.
✓ Branch 1 taken 437 times.
397790 if(intbtn & INT_BTN_R) ret |= getInput(btnR, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_R : 0;
9555
2/2
✓ Branch 0 taken 397353 times.
✓ Branch 1 taken 437 times.
397790 if(intbtn & INT_BTN_EX1) ret |= getInput(btnEx1, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX1 : 0;
9556
2/2
✓ Branch 0 taken 397353 times.
✓ Branch 1 taken 437 times.
397790 if(intbtn & INT_BTN_EX2) ret |= getInput(btnEx2, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX2 : 0;
9557
2/2
✓ Branch 0 taken 397353 times.
✓ Branch 1 taken 437 times.
397790 if(intbtn & INT_BTN_EX3) ret |= getInput(btnEx3, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX3 : 0;
9558
2/2
✓ Branch 0 taken 397353 times.
✓ Branch 1 taken 437 times.
397790 if(intbtn & INT_BTN_EX4) ret |= getInput(btnEx4, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX4 : 0;
9559 397790 return ret; //No early return, to make sure all button presses are eaten that should be! -Em
9560 }
9561
9562 1114 byte checkIntBtnVal(byte intbtn, byte vals)
9563 {
9564 1114 return intbtn&vals;
9565 }
9566
9567 924476 bool Up()
9568 {
9569 924476 return getInput(btnUp);
9570 }
9571 52368 bool Down()
9572 {
9573 52368 return getInput(btnDown);
9574 }
9575 141640 bool Left()
9576 {
9577 141640 return getInput(btnLeft);
9578 }
9579 163230 bool Right()
9580 {
9581 163230 return getInput(btnRight);
9582 }
9583 42106 bool cAbtn()
9584 {
9585 42106 return getInput(btnA);
9586 }
9587 683862 bool cBbtn()
9588 {
9589 683862 return getInput(btnB);
9590 }
9591 bool cSbtn()
9592 {
9593 return getInput(btnS);
9594 }
9595 6440 bool cLbtn()
9596 {
9597 6440 return getInput(btnL);
9598 }
9599 6440 bool cRbtn()
9600 {
9601 6440 return getInput(btnR);
9602 }
9603 bool cPbtn()
9604 {
9605 return getInput(btnP);
9606 }
9607 bool cEx1btn()
9608 {
9609 return getInput(btnEx1);
9610 }
9611 bool cEx2btn()
9612 {
9613 return getInput(btnEx2);
9614 }
9615 bool cEx3btn()
9616 {
9617 return getInput(btnEx3);
9618 }
9619 bool cEx4btn()
9620 {
9621 return getInput(btnEx4);
9622 }
9623 bool AxisUp()
9624 {
9625 return getInput(btnAxisUp);
9626 }
9627 bool AxisDown()
9628 {
9629 return getInput(btnAxisDown);
9630 }
9631 bool AxisLeft()
9632 {
9633 return getInput(btnAxisLeft);
9634 }
9635 bool AxisRight()
9636 {
9637 return getInput(btnAxisRight);
9638 }
9639
9640 bool cMbtn()
9641 {
9642 return getInput(btnM);
9643 }
9644 bool cF12()
9645 {
9646 return getInput(btnF12);
9647 }
9648 bool cF11()
9649 {
9650 return getInput(btnF11);
9651 }
9652 bool cF5()
9653 {
9654 return getInput(btnF5);
9655 }
9656 bool cQ()
9657 {
9658 return getInput(btnQ);
9659 }
9660 bool cI()
9661 {
9662 return getInput(btnI);
9663 }
9664
9665 68750 bool rUp()
9666 {
9667 68750 return getInput(btnUp, true);
9668 }
9669 68692 bool rDown()
9670 {
9671 68692 return getInput(btnDown, true);
9672 }
9673 68646 bool rLeft()
9674 {
9675 68646 return getInput(btnLeft, true);
9676 }
9677 68210 bool rRight()
9678 {
9679 68210 return getInput(btnRight, true);
9680 }
9681 2367 bool rAbtn()
9682 {
9683 2367 return getInput(btnA, true);
9684 }
9685 69250 bool rBbtn()
9686 {
9687 69250 return getInput(btnB, true);
9688 }
9689 3851535 bool rSbtn()
9690 {
9691 3851535 return getInput(btnS, true);
9692 }
9693 4800616 bool rMbtn()
9694 {
9695 4800616 return getInput(btnM, true);
9696 }
9697 68032 bool rLbtn()
9698 {
9699 68032 return getInput(btnL, true);
9700 }
9701 68029 bool rRbtn()
9702 {
9703 68029 return getInput(btnR, true);
9704 }
9705 3788346 bool rPbtn()
9706 {
9707 3788346 return getInput(btnP, true);
9708 }
9709 bool rEx1btn()
9710 {
9711 return getInput(btnEx1, true);
9712 }
9713 bool rEx2btn()
9714 {
9715 return getInput(btnEx2, true);
9716 }
9717 78908 bool rEx3btn()
9718 {
9719 78908 return getInput(btnEx3, true);
9720 }
9721 78908 bool rEx4btn()
9722 {
9723 78908 return getInput(btnEx4, true);
9724 }
9725 bool rAxisUp()
9726 {
9727 return getInput(btnAxisUp, true);
9728 }
9729 bool rAxisDown()
9730 {
9731 return getInput(btnAxisDown, true);
9732 }
9733 bool rAxisLeft()
9734 {
9735 return getInput(btnAxisLeft, true);
9736 }
9737 bool rAxisRight()
9738 {
9739 return getInput(btnAxisRight, true);
9740 }
9741
9742 bool rF11()
9743 {
9744 return getInput(btnF11, true);
9745 }
9746 bool rQ()
9747 {
9748 return getInput(btnQ, true);
9749 }
9750 bool rI()
9751 {
9752 return getInput(btnI, true);
9753 }
9754
9755 9990591 bool DrunkUp()
9756 {
9757 9990591 return getInput(btnUp, false, true);
9758 }
9759 9331462 bool DrunkDown()
9760 {
9761 9331462 return getInput(btnDown, false, true);
9762 }
9763 5913521 bool DrunkLeft()
9764 {
9765 5913521 return getInput(btnLeft, false, true);
9766 }
9767 5138042 bool DrunkRight()
9768 {
9769 5138042 return getInput(btnRight, false, true);
9770 }
9771 4281541 bool DrunkcAbtn()
9772 {
9773 4281541 return getInput(btnA, false, true);
9774 }
9775 4182505 bool DrunkcBbtn()
9776 {
9777 4182505 return getInput(btnB, false, true);
9778 }
9779 3781589 bool DrunkcEx1btn()
9780 {
9781 3781589 return getInput(btnEx1, false, true);
9782 }
9783 3781609 bool DrunkcEx2btn()
9784 {
9785 3781609 return getInput(btnEx2, false, true);
9786 }
9787 bool DrunkcSbtn()
9788 {
9789 return getInput(btnS, false, true);
9790 }
9791 bool DrunkcMbtn()
9792 {
9793 return getInput(btnM, false, true);
9794 }
9795 bool DrunkcLbtn()
9796 {
9797 return getInput(btnL, false, true);
9798 }
9799 bool DrunkcRbtn()
9800 {
9801 return getInput(btnR, false, true);
9802 }
9803 bool DrunkcPbtn()
9804 {
9805 return getInput(btnP, false, true);
9806 }
9807
9808 bool DrunkrUp()
9809 {
9810 return getInput(btnUp, true, true);
9811 }
9812 bool DrunkrDown()
9813 {
9814 return getInput(btnDown, true, true);
9815 }
9816 bool DrunkrLeft()
9817 {
9818 return getInput(btnLeft, true, true);
9819 }
9820 bool DrunkrRight()
9821 {
9822 return getInput(btnRight, true, true);
9823 }
9824 3152476 bool DrunkrAbtn()
9825 {
9826 3152476 return getInput(btnA, true, true);
9827 }
9828 3143791 bool DrunkrBbtn()
9829 {
9830 3143791 return getInput(btnB, true, true);
9831 }
9832 71669 bool DrunkrEx1btn()
9833 {
9834 71669 return getInput(btnEx1, true, true);
9835 }
9836 71662 bool DrunkrEx2btn()
9837 {
9838 71662 return getInput(btnEx2, true, true);
9839 }
9840 bool DrunkrEx3btn()
9841 {
9842 return getInput(btnEx3, true, true);
9843 }
9844 bool DrunkrEx4btn()
9845 {
9846 return getInput(btnEx4, true, true);
9847 }
9848 bool DrunkrSbtn()
9849 {
9850 return getInput(btnS, true, true);
9851 }
9852 bool DrunkrMbtn()
9853 {
9854 return getInput(btnM, true, true);
9855 }
9856 3462285 bool DrunkrLbtn()
9857 {
9858 3462285 return getInput(btnL, true, true);
9859 }
9860 3460467 bool DrunkrRbtn()
9861 {
9862 3460467 return getInput(btnR, true, true);
9863 }
9864 bool DrunkrPbtn()
9865 {
9866 return getInput(btnP, true, true);
9867 }
9868
9869 4964 void eat_buttons()
9870 {
9871 4964 getInput(btnA, true, false, true);
9872 4964 getInput(btnB, true, false, true);
9873 4964 getInput(btnS, true, false, true);
9874 4964 getInput(btnM, true, false, true);
9875 4964 getInput(btnL, true, false, true);
9876 4964 getInput(btnR, true, false, true);
9877 4964 getInput(btnP, true, false, true);
9878 4964 getInput(btnEx1, true, false, true);
9879 4964 getInput(btnEx2, true, false, true);
9880 4964 getInput(btnEx3, true, false, true);
9881 4964 getInput(btnEx4, true, false, true);
9882 4964 }
9883
9884 // Is true for the _first frame_ of a key press.
9885 // But! it is possible that a script manually sets the value of KeyPress,
9886 // in which case it will be restored to the "true" value based on `key_current_frame`
9887 // and `key_previous_frame` on the next frame.
9888 14 bool zc_readkey(int32_t k, bool ignoreDisable)
9889 {
9890
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(ignoreDisable) return KeyPress[k];
9891
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 switch(k)
9892 {
9893 case KEY_F7:
9894 case KEY_F8:
9895 case KEY_F9:
9896 return KeyPress[k];
9897
9898 default:
9899
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 1 times.
14 return KeyPress[k] && !disabledKeys[k];
9900 }
9901 14 }
9902
9903 // Is true for _every frame_ a key is held down.
9904 // But! it is possible that a script manually sets the value of KeyInput,
9905 // in which case it will be restored to the "true" value based on `key_current_frame`
9906 // on the next frame.
9907 bool zc_getkey(int32_t k, bool ignoreDisable)
9908 {
9909 if(ignoreDisable) return KeyInput[k];
9910 switch(k)
9911 {
9912 case KEY_F7:
9913 case KEY_F8:
9914 case KEY_F9:
9915 return KeyInput[k];
9916
9917 default:
9918 return KeyInput[k] && !disabledKeys[k];
9919 }
9920 }
9921
9922 // Reads (and then clears) the current frame key state directly.
9923 // Scripts can also modify `key_current_frame`.
9924 88 bool zc_readrawkey(int32_t k, bool ignoreDisable)
9925 {
9926
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 87 times.
88 if(zc_getrawkey(k, ignoreDisable))
9927 {
9928 1 _key[k]=key[k]=key_current_frame[k]=0;
9929 1 return true;
9930 }
9931 87 _key[k]=key[k]=key_current_frame[k]=0;
9932 87 return false;
9933 88 }
9934
9935 // Reads the current frame key state directly.
9936 // Scripts can also modify `key_current_frame`.
9937 31353397 bool zc_getrawkey(int32_t k, bool ignoreDisable)
9938 {
9939
2/2
✓ Branch 0 taken 26552753 times.
✓ Branch 1 taken 4800644 times.
31353397 if(ignoreDisable) return key_current_frame[k];
9940
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4800644 times.
4800644 switch(k)
9941 {
9942 case KEY_F7:
9943 case KEY_F8:
9944 case KEY_F9:
9945 return key_current_frame[k];
9946
9947 default:
9948
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4800644 times.
4800644 return key_current_frame[k] && !disabledKeys[k];
9949 }
9950 31353397 }
9951
9952 // Only used for a handful of keys, like tilde and Function keys.
9953 // This state is never read within the game.
9954 // It exists so that all keyboard input still functions during replay,
9955 // without inadvertently doing things like toggling throttling if the player
9956 // presses ~
9957 9601291 bool zc_get_system_key(int32_t k)
9958 {
9959 9601291 return key_system[k];
9960 }
9961
9962 // True for the _first_ frame of a key press.
9963 43205544 bool zc_read_system_key(int32_t k)
9964 {
9965 43205544 return key_system_press[k];
9966 }
9967
9968 609678232 bool is_system_key(int32_t k)
9969 {
9970
2/2
✓ Branch 0 taken 566472688 times.
✓ Branch 1 taken 43205544 times.
609678232 switch (k)
9971 {
9972 case KEY_BACKQUOTE:
9973 case KEY_CLOSEBRACE:
9974 case KEY_END:
9975 case KEY_HOME:
9976 case KEY_OPENBRACE:
9977 case KEY_PGDN:
9978 case KEY_PGUP:
9979 case KEY_TAB:
9980 case KEY_TILDE:
9981 43205544 return true;
9982 }
9983 566472688 return is_Fkey(k);
9984 609678232 }
9985
9986 4800616 void update_system_keys()
9987 {
9988
2/2
✓ Branch 0 taken 609678232 times.
✓ Branch 1 taken 4800616 times.
614478848 for (int32_t q = 0; q < 127; ++q)
9989 {
9990
2/2
✓ Branch 0 taken 100812936 times.
✓ Branch 1 taken 508865296 times.
609678232 if (!is_system_key(q))
9991 508865296 continue;
9992
9993 100812936 key_system[q] = key[q];
9994
1/2
✓ Branch 0 taken 100812936 times.
✗ Branch 1 not taken.
100812936 key_system_press[q] = key_system[q] && !key_system_previous[q];
9995 100812936 key_system_previous[q] = key_system[q];
9996 100812936 }
9997 4800616 }
9998
9999 5918082 void update_keys()
10000 {
10001
2/2
✓ Branch 0 taken 751596414 times.
✓ Branch 1 taken 5918082 times.
757514496 for (int32_t q = 0; q < 127; ++q)
10002 {
10003 // When replaying, replay.cpp takes care of updating `key_current_frame`.
10004
1/2
✓ Branch 0 taken 751596414 times.
✗ Branch 1 not taken.
751596414 if (!replay_is_replaying())
10005 key_current_frame[q] = key[q];
10006
10007
2/2
✓ Branch 0 taken 746262464 times.
✓ Branch 1 taken 5333950 times.
751596414 KeyPress[q] = key_current_frame[q] && !key_previous_frame[q];
10008 751596414 KeyInput[q] = key_current_frame[q];
10009 751596414 key_previous_frame[q] = key_current_frame[q];
10010 751596414 }
10011 5918082 }
10012
10013 bool zc_disablekey(int32_t k, bool val)
10014 {
10015 switch(k)
10016 {
10017 case KEY_F7:
10018 case KEY_F8:
10019 case KEY_F9:
10020 return false;
10021
10022 default:
10023 disabledKeys[k] = val;
10024 return true;
10025 }
10026 }
10027
10028 void zc_putpixel(int32_t layer, int32_t x, int32_t y, int32_t cset, int32_t color, int32_t timer)
10029 {
10030 timer=timer;
10031 particles.add(new particle(zfix(x), zfix(y), layer, cset, color));
10032 }
10033
10034 // these are here so that copy_dialog won't choke when compiling zelda
10035 int32_t d_alltriggerbutton_proc(int32_t, DIALOG*, int32_t)
10036 {
10037 return D_O_K;
10038 }
10039
10040 int32_t d_comboa_radio_proc(int32_t, DIALOG*, int32_t)
10041 {
10042 return D_O_K;
10043 }
10044
10045 int32_t d_comboabutton_proc(int32_t, DIALOG*, int32_t)
10046 {
10047 return D_O_K;
10048 }
10049
10050 int32_t d_ssdn_btn_proc(int32_t, DIALOG*, int32_t)
10051 {
10052 return D_O_K;
10053 }
10054
10055 int32_t d_ssdn_btn2_proc(int32_t, DIALOG*, int32_t)
10056 {
10057 return D_O_K;
10058 }
10059
10060 int32_t d_ssdn_btn3_proc(int32_t, DIALOG*, int32_t)
10061 {
10062 return D_O_K;
10063 }
10064
10065 int32_t d_ssdn_btn4_proc(int32_t, DIALOG*, int32_t)
10066 {
10067 return D_O_K;
10068 }
10069
10070 int32_t d_sslt_btn_proc(int32_t, DIALOG*, int32_t)
10071 {
10072 return D_O_K;
10073 }
10074
10075 int32_t d_sslt_btn2_proc(int32_t, DIALOG*, int32_t)
10076 {
10077 return D_O_K;
10078 }
10079
10080 int32_t d_sslt_btn3_proc(int32_t, DIALOG*, int32_t)
10081 {
10082 return D_O_K;
10083 }
10084
10085 int32_t d_sslt_btn4_proc(int32_t, DIALOG*, int32_t)
10086 {
10087 return D_O_K;
10088 }
10089
10090 int32_t d_ssrt_btn_proc(int32_t, DIALOG*, int32_t)
10091 {
10092 return D_O_K;
10093 }
10094
10095 int32_t d_ssrt_btn2_proc(int32_t, DIALOG*, int32_t)
10096 {
10097 return D_O_K;
10098 }
10099
10100 int32_t d_ssrt_btn3_proc(int32_t, DIALOG*, int32_t)
10101 {
10102 return D_O_K;
10103 }
10104
10105 int32_t d_ssrt_btn4_proc(int32_t, DIALOG*, int32_t)
10106 {
10107 return D_O_K;
10108 }
10109
10110 int32_t d_ssup_btn_proc(int32_t, DIALOG*, int32_t)
10111 {
10112 return D_O_K;
10113 }
10114
10115 int32_t d_ssup_btn2_proc(int32_t, DIALOG*, int32_t)
10116 {
10117 return D_O_K;
10118 }
10119
10120 int32_t d_ssup_btn3_proc(int32_t, DIALOG*, int32_t)
10121 {
10122 return D_O_K;
10123 }
10124
10125 int32_t d_ssup_btn4_proc(int32_t, DIALOG*, int32_t)
10126 {
10127 return D_O_K;
10128 }
10129
10130 int32_t d_tri_edit_proc(int32_t, DIALOG*, int32_t)
10131 {
10132 return D_O_K;
10133 }
10134
10135 int32_t d_triggerbutton_proc(int32_t, DIALOG*, int32_t)
10136 {
10137 return D_O_K;
10138 }
10139
10140 /*** end of zc_sys.cc ***/
10141
10142